Skip to content

Commit

Permalink
added action validation (#40)
Browse files Browse the repository at this point in the history
I had many times the problem of setting the action to point to its own
branch to test, only to forget about setting it again to the main
branch.

This adds a check that makes the PR fails unless that the branch is
actually pointing to main.
  • Loading branch information
Bullrich authored Aug 8, 2023
1 parent 88feb92 commit 37306a9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,24 @@ jobs:
- uses: actions/[email protected]
- name: Check that the image builds
run: docker build . --file Dockerfile
validate-action:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
# This checks that .github/workflows/review-bot.yml is pointing towards the main branch
# as, during development, we change this to use the code from the test branch and
# we may forget to set it back to main
- name: Validate that action points to main branch
run: |
BRANCH=$(yq '.jobs.review-approvals.steps[0].uses' $FILE_NAME | cut -d "@" -f2)
# If the branch is not the main branch
if [ "$BRANCH" != "$GITHUB_BASE_REF" ]; then
echo "Action points to $BRANCH. It has to point to $GITHUB_BASE_REF instead!"
exit 1
else
echo "Action is correctly pointing to $GITHUB_BASE_REF"
fi
env:
FILE_NAME: ".github/workflows/review-bot.yml"

# Todo: Add the rest of the action https://github.com/paritytech/stale-pr-finder/blob/main/.github/workflows/publish.yml
3 changes: 2 additions & 1 deletion .github/workflows/review-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
review-approvals:
runs-on: ubuntu-latest
steps:
# TODO: Set this to main
# !This must always point to main.
# Change it for the PRs but remember to change it back
- uses: paritytech/review-bot@main
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down

0 comments on commit 37306a9

Please sign in to comment.