This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
Added ability to make push trigger actions (#25) #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish action | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
IMAGE_NAME: action | |
REGISTRY: ghcr.io | |
jobs: | |
test-image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check that the image builds | |
run: docker build . --file Dockerfile | |
validate-action: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
steps: | |
- uses: actions/checkout@v4 | |
# This checks that .github/workflows/cmd-action.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 cmd-check points to main branch | |
run: | | |
BRANCH=$(yq '.jobs.cmd-check.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/cmd-action.yml" | |
- name: Validate that cmd-run points to main branch | |
run: | | |
BRANCH=$(yq '.jobs.cmd-run.steps[2].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/cmd-action.yml" |