From 22f6a11f8d3340958f7cefeacc6ca57b01b4f200 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 21 Dec 2024 16:01:26 +0100 Subject: [PATCH] GH Actions: add actionlint job This job checks the GH Actions workflows against syntax errors and other problems. Includes minor fixes to pre-existing workflows to allow the build to pass. --- .github/workflows/cs.yml | 18 +++++++++++------- .github/workflows/deploy.yml | 10 +++++----- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index c80bc68..9dbc1e8 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -11,7 +11,7 @@ on: - 'composer.lock' - '.phpcs.xml.dist' - 'phpcs.xml.dist' - - '.github/workflows/cs.yml' + - '.github/workflows/**' pull_request: paths: - '**.php' @@ -19,7 +19,7 @@ on: - 'composer.lock' - '.phpcs.xml.dist' - 'phpcs.xml.dist' - - '.github/workflows/cs.yml' + - '.github/workflows/**' # Allow manually triggering the workflow. workflow_dispatch: @@ -30,6 +30,10 @@ concurrency: cancel-in-progress: true jobs: + actionlint: + name: 'Lint GH Action workflows' + uses: Yoast/.github/.github/workflows/reusable-actionlint.yml@main + checkcs: name: 'Check code style' runs-on: ubuntu-latest @@ -44,11 +48,11 @@ jobs: BASE_REF: ${{ github.base_ref }} run: | if [ "${{ github.event_name }}" == "pull_request" ]; then - echo "NAME=$BASE_REF" >> $GITHUB_OUTPUT - echo "REF=origin/$BASE_REF" >> $GITHUB_OUTPUT + echo "NAME=$BASE_REF" >> "$GITHUB_OUTPUT" + echo "REF=origin/$BASE_REF" >> "$GITHUB_OUTPUT" else - echo 'NAME=develop' >> $GITHUB_OUTPUT - echo "REF=origin/develop" >> $GITHUB_OUTPUT + echo 'NAME=develop' >> "$GITHUB_OUTPUT" + echo "REF=origin/develop" >> "$GITHUB_OUTPUT" fi - name: Fetch base branch @@ -83,7 +87,7 @@ jobs: set +e composer check-cs-thresholds exitcode="$?" - echo "EXITCODE=$exitcode" >> $GITHUB_OUTPUT + echo "EXITCODE=$exitcode" >> "$GITHUB_OUTPUT" exit "$exitcode" # Check the codestyle only of the files which were changed in the current branch. diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8899008..976062c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -135,11 +135,11 @@ jobs: REF_NAME: ${{ github.ref_name }} run: | if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref_type }}" == 'tag' ]]; then - echo "BRANCH=${{ env.DIST_DEFAULT_BRANCH }}" >> $GITHUB_OUTPUT - echo "TITLE=Release $REF_NAME" >> $GITHUB_OUTPUT + echo "BRANCH=${{ env.DIST_DEFAULT_BRANCH }}" >> "$GITHUB_OUTPUT" + echo "TITLE=Release $REF_NAME" >> "$GITHUB_OUTPUT" else # = manually triggered. - echo "BRANCH=$REF_NAME" >> $GITHUB_OUTPUT - echo "TITLE=Manual deploy for $REF_NAME" >> $GITHUB_OUTPUT + echo "BRANCH=$REF_NAME" >> "$GITHUB_OUTPUT" + echo "TITLE=Manual deploy for $REF_NAME" >> "$GITHUB_OUTPUT" fi - name: Checkout Yoast Dist repo @@ -212,7 +212,7 @@ jobs: if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} env: REF_NAME: ${{ github.ref_name }} - run: git tag "$REF_NAME" $(git rev-parse HEAD) + run: git tag "$REF_NAME" "$(git rev-parse HEAD)" - name: Push to target branch run: git push -u origin ${{ steps.set_vars.outputs.BRANCH }} --tags -v