From c064fee3dbcd7fd83353fd9522cd6ca02bace0d1 Mon Sep 17 00:00:00 2001 From: Mert Can Altin Date: Sat, 21 Sep 2024 15:41:47 +0300 Subject: [PATCH] tools: add WPT updater for specific subsystems --- .github/workflows/update-wpt.yml | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/update-wpt.yml diff --git a/.github/workflows/update-wpt.yml b/.github/workflows/update-wpt.yml new file mode 100644 index 00000000000000..8191ef90562aca --- /dev/null +++ b/.github/workflows/update-wpt.yml @@ -0,0 +1,76 @@ +name: WPT update + +on: + schedule: + # Run once a week at 12:00 AM UTC on Sunday. + - cron: 0 0 * * * + workflow_dispatch: + inputs: + subsystems: + description: Subsystem to run the update for + required: false + default: '["url"]' + +permissions: + contents: read + +jobs: + wpt-subsystem-update: + if: github.repository == 'nodejs/node' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + subsystem: ${{ fromJSON(github.event.inputs.subsystems || '["url"]') }} + + steps: + - uses: actions/checkout@v4.1.7 + with: + persist-credentials: false + + - name: Install @node-core/utils + run: | + npm install -g @node-core/utils + + - name: Calculate new version for WPT + run: | + # Hypothetically, you can get the latest version from a specific file or git log + new_version=$(git log -1 --pretty=format:"%h") + echo "new_version=$new_version" >> $GITHUB_ENV + + - name: Compare versions + run: | + echo "Comparing current version to new version ${{ env.new_version }}" + + - name: Update WPT for subsystem ${{ matrix.subsystem }} + run: | + git node wpt ${{ matrix.subsystem }} + env: + GH_TOKEN: ${{ secrets.GH_USER_TOKEN }} + + - name: Handle changes + run: | + if [[ "$(git status --porcelain)" != "" ]]; then + git config --global user.name "${{ github.actor }}[bot]" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git checkout -b actions/update-wpt-${{ matrix.subsystem }} + git add . + git commit -m "test: update WPT for ${{ matrix.subsystem }} to ${{ env.new_version }}" + gh auth setup-git + git push origin actions/update-wpt-${{ matrix.subsystem }} -fu --no-verify + echo "createPR=true" >> "$GITHUB_OUTPUT" + else + echo "No changes to commit." + fi + env: + GH_TOKEN: ${{ secrets.GH_USER_TOKEN }} + + - name: Open or update PR for the subsystem update + if: steps.push-changes.outputs.createPR + uses: gr2m/create-or-update-pull-request-action@86ec1766034c8173518f61d2075cc2a173fb8c97 + with: + token: ${{ secrets.GH_USER_TOKEN }} + branch: actions/update-wpt-${{ matrix.subsystem }} + title: 'test: update WPT for ${{ matrix.subsystem }} to ${{ env.new_version }}' + body: | + This is an automated update of the WPT for ${{ matrix.subsystem }} to ${{ env.new_version }}.