Skip to content

Commit

Permalink
Pre run script automation (#2213)
Browse files Browse the repository at this point in the history
* Created a workflow to update the pre run script for the integration tests

* Update update-prerun-script.yml

* Changed the workflow run

Changed it to run on every push for testing

* Changed the payload path

* Update update-prerun-script.yml

* Combined the two jobs

* Added code to checkout package

* Added permissions to Github token

* Changed how PR is created

* Added commands to commit before PR

* Changed the git commit command

* Update update-prerun-script.yml

* Update update-prerun-script.yml

* Removed commit statements

* Update update-prerun-script.yml

* Split the two PRs

* Created new action to upload pre run script

* Combined get-previous-version and create PR tasks

* Changed from using tags to commit hash
  • Loading branch information
jhaarpan authored May 26, 2022
1 parent a030477 commit 1382a28
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/update-prerun-script.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Update pre build script on Saucelabs

on:
schedule:
- cron: '*/10 * * * *'
# schedule:
# - cron: '0 0 1 */2 *'
permissions:
contents: read
pull-requests: write

env:
SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}

jobs:
update-pre-run-script:
name: Update pre run script on Saucelabs
runs-on: ubuntu-latest
outputs:
script-id: ${{ steps.upload-pre-run-script.outputs.script-id }}
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Copy script from S3 bucket
run: aws s3 cp s3://saucelabs-prebuild-script/script.sh ./
- name: Upload pre run script to Saucelabs
id: upload-pre-run-script
run: |
RESPONSE="$(curl -u "$SAUCE_USERNAME:$SAUCE_ACCESS_KEY" —location --request POST 'https://api.us-west-1.saucelabs.com/v1/storage/upload' --form 'payload=@"script.sh"' --form 'name="blur_replacement_script"')"
SCRIPT_ID=$(jq -r '.item.id' <<< "$RESPONSE")
rm -rf script.sh
echo "::set-output name=script-id::$SCRIPT_ID"
create-pr:
name: Create PR for origin branch
runs-on: ubuntu-latest
needs: [update-pre-run-script]
steps:
- name: Checkout Package
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update pre run script ID
run: |
echo "Updating integration tests pre-run script ID for origin branch"
SCRIPT_ID=${{ needs.update-pre-run-script.outputs.script-id }}
sed -i -E "s/storage.*'/storage:$SCRIPT_ID'/g" ${GITHUB_WORKSPACE}/integration/js/utils/WebdriverSauceLabs.js
- name: Create Pull Request
uses: peter-evans/create-pull-request@f094b77505fb89581e68a1163fbd2fffece39da1
with:
commit-message: Update integration tests pre-run script ID
title: Update integration tests pre-run script ID
branch: update-pre-run-script-id
base: main
delete-branch: true

create-pr-previous-version:
name: Create PR for previous version
runs-on: ubuntu-latest
needs: [update-pre-run-script]
steps:
- name: Checkout Package
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Version
id: get-version
run: |
current_version=$(.github/script/get-current-version)
echo "::set-output name=version-number::$((${current_version%%.*} - 1))"
- name: Update pre run script ID
run: |
echo "Updating integration tests pre-run script ID for previous major version branch"
git checkout release-${{ steps.get-version.outputs.version-number }}.x
SCRIPT_ID=${{ needs.update-pre-run-script.outputs.script-id }}
sed -i -E "s/storage.*'/storage:$SCRIPT_ID'/g" ${GITHUB_WORKSPACE}/integration/js/utils/WebdriverSauceLabs.js
- name: Create Pull Request
uses: peter-evans/create-pull-request@f094b77505fb89581e68a1163fbd2fffece39da1
with:
commit-message: Update integration tests pre-run script ID
title: Update integration tests pre-run script ID for previous release
branch: update-pre-run-script-id-previous-release
delete-branch: true

0 comments on commit 1382a28

Please sign in to comment.