diff --git a/.github/workflows/update-prerun-script.yml b/.github/workflows/update-prerun-script.yml new file mode 100644 index 0000000000..184ffbccd5 --- /dev/null +++ b/.github/workflows/update-prerun-script.yml @@ -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