Skip to content

Commit

Permalink
Update APG to WAI pipeline workflows to handle desync issues and …
Browse files Browse the repository at this point in the history
…better reports on errors (#361)

* Fix #219
* Update 'deploy.yml' to use 'w3cgruntbot' as committer
* Update 'pr-create.yml' to force a rebase to happen with main in the case generated branch doesn't have relevant changes; additional error handling coverage with 'create-pr' script
* For consistency, rename 'create-pr' script to 'pr-create'
* Remove unnecessary delete branch action
  • Loading branch information
howard-e authored Dec 12, 2024
1 parent 9343ecc commit 9bc78c8
Show file tree
Hide file tree
Showing 9 changed files with 508 additions and 514 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ jobs:
node ./scripts/pre-build
- name: Commit changed files and submodule updates
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Commit changes
commit_user_name: w3cgruntbot
commit_user_email: [email protected]
commit_author: w3cgruntbot <[email protected]>
commit_message: "chore: Update `main` with latest changes from `aria-practices`"
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 27 additions & 19 deletions .github/workflows/pr-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ on:
required: false

jobs:
create-pr:
pr-create:
runs-on: ubuntu-latest

steps:
- name: Get current job and log url
uses: Tiryoh/gha-jobid-action@v0
uses: Tiryoh/gha-jobid-action@v1
id: jobs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: create-pr
job_name: pr-create

- uses: actions/checkout@v4
with:
Expand All @@ -45,26 +45,30 @@ jobs:
ruby-version: 3.3

- name: Update git submodules
if: github.event.inputs.fork_path == 'false'
run: |
git submodule update --recursive --remote
cd _external/aria-practices
if [ -n "${{ github.event.inputs.fork_path }}" ] && [ "${{ github.event.inputs.fork_path }}" != 'false' ]; then
echo "Found fork: ${{ github.event.inputs.fork_path }}"
git remote add fork https://github.com/${{ github.event.inputs.fork_path }}.git
git fetch fork
fi
git checkout ${{ github.event.inputs.apg_sha }}
- name: Update git submodules from fork
if: github.event.inputs.fork_path != 'false'
run: |
git submodule update --recursive --remote
cd _external/aria-practices
git remote add fork https://github.com/${{ github.event.inputs.fork_path }}.git
git fetch fork
git checkout ${{ github.event.inputs.apg_sha }}
- name: Switch to and create/update branch
- name: Switch to and create or update branch
run: |
# switch to branch if exists or create branch
git switch apg/${{ github.event.inputs.apg_branch }} 2>/dev/null || git switch -c apg/${{ github.event.inputs.apg_branch }}
- name: Force rebase the switched branch onto main
run: |
git config --global user.name "w3cgruntbot"
git config --global user.email "[email protected]"
git fetch origin main
git rebase --force-rebase origin/main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update site files
id: update_site_files
working-directory: ./
Expand All @@ -76,19 +80,23 @@ jobs:

- name: Commit changed files and submodule updates
if: steps.update_site_files.outcome == 'success'
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Commit changed files and submodule updates
commit_user_name: w3cgruntbot
commit_user_email: [email protected]
commit_author: w3cgruntbot <[email protected]>
commit_message: "chore: Update branch with latest `${{ github.event.inputs.apg_branch }}` changes and submodule updates"
branch: apg/${{ github.event.inputs.apg_branch }}
push_options: '--force'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create pull request
- name: Create or update pull request
working-directory: ./
run: |
npm install -C scripts/create-pr
node ./scripts/create-pr
set -e
npm install -C scripts/pr-create
node ./scripts/pr-create
env:
GH_TOKEN: ${{ secrets.W3CGRUNTBOT_TOKEN }}
APG_SHA: ${{ github.event.inputs.apg_sha }}
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/remove-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check if branch exists
id: check_if_exists
run: |
OUTPUT=$(git ls-remote --heads https://github.com/${{ github.repository_owner }}/wai-aria-practices.git apg/${{ github.event.inputs.apg_branch }} | wc -l)
echo "::set-output name=branch-exists::$(echo $OUTPUT)"
BRANCH_EXISTS=$(git ls-remote --heads https://github.com/${{ github.repository_owner }}/wai-aria-practices.git apg/${{ github.event.inputs.apg_branch }} | wc -l)
echo "BRANCH_EXISTS=$BRANCH_EXISTS" >> "$GITHUB_OUTPUT"
- name: Clean up generated branch
if: ${{ steps.check_if_exists.outputs.branch-exists == '1' }}
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ github.token }}
branches: apg/${{ github.event.inputs.apg_branch }}
if: ${{ steps.check_if_exists.outputs.BRANCH_EXISTS == '1' }}
run: |
BRANCH_NAME="apg/${{ github.event.inputs.apg_branch }}"
git config --global user.name "w3cgruntbot"
git config --global user.email "[email protected]"
git push origin --delete $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Report branch already removed
if: ${{ steps.check_if_exists.outputs.branch-exists == '0' }}
if: ${{ steps.check_if_exists.outputs.BRANCH_EXISTS == '0' }}
run: echo "Branch already removed"
108 changes: 0 additions & 108 deletions scripts/create-pr/index.js

This file was deleted.

Loading

0 comments on commit 9bc78c8

Please sign in to comment.