Skip to content

Commit

Permalink
CI: add GitHub Actions workflow linter (#594)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Aug 23, 2023
1 parent c4e1abf commit 8b97a41
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 25 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
NODE_ARCH=amd64
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${NODE_ARCH/\//}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> $GITHUB_ENV
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
cp package.json build/
docker run --rm --platform "linux/${NODE_ARCH}" --volume "$(pwd):/app" --workdir "/app" \
"node:$(cat .nvmrc)" sh -c \
Expand All @@ -37,7 +37,7 @@ jobs:
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
NODE_ARCH=arm/v7
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${NODE_ARCH/\//}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> $GITHUB_ENV
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
cp package.json build/
docker run --rm --platform "linux/${NODE_ARCH}" --volume "$(pwd):/app" --workdir "/app" \
"node:$(cat .nvmrc)" sh -c \
Expand All @@ -48,7 +48,7 @@ jobs:
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
NODE_ARCH=arm64/v8
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${NODE_ARCH/\//}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> $GITHUB_ENV
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
cp package.json build/
docker run --rm --platform "linux/${NODE_ARCH}" --volume "$(pwd):/app" --workdir "/app" \
"node:$(cat .nvmrc)" sh -c \
Expand All @@ -59,7 +59,7 @@ jobs:
NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')
NODE_ARCH=$(node --print 'process.arch')
BIN_OUTPUT="igir-${NPM_PKG_VERSION}-${RUNNER_OS}-${NODE_ARCH}.tar.gz"
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> $GITHUB_ENV
echo "BIN_OUTPUT=${BIN_OUTPUT}" >> "${GITHUB_ENV}"
cp package.json build/
./node_modules/.bin/caxa --input build/ --output igir -- "{{caxa}}/node_modules/.bin/node" "{{caxa}}/index.js"
./igir --help
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'
- run: npm ci
- run: echo "NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')" >> $GITHUB_ENV
- run: echo "NPM_PKG_VERSION=$(npm pkg get version | sed 's/"//g')" >> "${GITHUB_ENV}"
# Download and update
- uses: actions/download-artifact@v3
- uses: softprops/action-gh-release@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest --disable MD013 MD033 MD046 -- "**/*.md"
- run: docker run -v "${PWD}:/workdir" ghcr.io/igorshubovych/markdownlint-cli:latest --disable MD013 MD033 MD046 -- "**/*.md"

build:
if: github.event_name == 'pull_request'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pr-renamer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
fi
if [[ ! "${OLD_TITLE}" =~ ^[a-zA-Z\\(\\)\\!]+: ]]; then
echo "ERROR=No conventional commit type found. The allowed list is: ${ALLOWED_TYPES//|/, }" >> "$GITHUB_OUTPUT"
echo "ERROR=No conventional commit type found. The allowed list is: ${ALLOWED_TYPES//|/, }" >> "${GITHUB_OUTPUT}"
exit 1
fi
Expand All @@ -59,12 +59,12 @@ jobs:
# Restrict types
if [[ ! "${NEW_TITLE}" =~ ^${ALLOWED_TYPES}: ]]; then
echo "ERROR=The conventional commit type isn't in the allowed list: ${ALLOWED_TYPES//|/, }" >> "$GITHUB_OUTPUT"
echo "ERROR=The conventional commit type isn't in the allowed list: ${ALLOWED_TYPES//|/, }" >> "${GITHUB_OUTPUT}"
exit 1
fi
echo "OLD_TITLE=${OLD_TITLE}" >> "$GITHUB_OUTPUT"
echo "NEW_TITLE=${NEW_TITLE}" >> "$GITHUB_OUTPUT"
echo "OLD_TITLE=${OLD_TITLE}" >> "${GITHUB_OUTPUT}"
echo "NEW_TITLE=${NEW_TITLE}" >> "${GITHUB_OUTPUT}"
# Required for `gh` CLI
- uses: actions/checkout@v3
- id: gh-pr-edit
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ jobs:
id: auto-changelog
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "MARKDOWN<<$EOF" >> "$GITHUB_OUTPUT"
./scripts/auto-changelog.sh >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
{
echo "MARKDOWN<<$EOF"
./scripts/auto-changelog.sh
echo ""
echo ""
echo "$EOF"
} >> "$GITHUB_OUTPUT"
# Create/update the draft release
- if: steps.check.outputs.changed == 'true'
Expand All @@ -80,6 +82,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- if: ${{ steps.release-drafter.outputs.id }}
run: |
echo "# v${{ steps.check.outputs.version }} @ ${{ env.ref }}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "${{ steps.release-drafter.outputs.html_url }}" >> "$GITHUB_STEP_SUMMARY"
{
echo "# v${{ steps.check.outputs.version }} @ ${{ env.ref }}"
echo ""
echo "${{ steps.release-drafter.outputs.html_url }}"
} >> "$GITHUB_STEP_SUMMARY"
16 changes: 9 additions & 7 deletions .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ jobs:
git add --all
USER_EMAIL="${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com"
echo "USER_EMAIL=${USER_EMAIL}" >> "$GITHUB_OUTPUT"
echo "USER_EMAIL=${USER_EMAIL}" >> "${GITHUB_OUTPUT}"
git config --global user.email "${USER_EMAIL}"
USER_NAME="$(gh api /users/${GITHUB_ACTOR} | jq .name -r)"
echo "USER_NAME=${USER_NAME}" >> "$GITHUB_OUTPUT"
USER_NAME="$(gh api "/users/${GITHUB_ACTOR}" | jq .name -r)"
echo "USER_NAME=${USER_NAME}" >> "${GITHUB_OUTPUT}"
git config --global user.name "${USER_NAME}"
PACKAGE_VERSION="$(jq --raw-output '.version' package.json)"
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "$GITHUB_OUTPUT"
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> "${GITHUB_OUTPUT}"
git commit -m "v${PACKAGE_VERSION}"
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -69,9 +69,11 @@ jobs:
reviewers: ${{ (!inputs.auto-merge && github.repository_owner != github.actor) && github.repository_owner || '' }}
- if: ${{ steps.create-pull-request.outputs.pull-request-number }}
run: |
echo "# v${{ steps.bump-and-commit.outputs.PACKAGE_VERSION }}" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
echo "${{ steps.create-pull-request.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY"
{
echo "# v${{ steps.bump-and-commit.outputs.PACKAGE_VERSION }}"
echo ""
echo "${{ steps.create-pull-request.outputs.pull-request-url }}"
} >> "$GITHUB_STEP_SUMMARY"
- if: ${{ steps.create-pull-request.outputs.pull-request-number && inputs.auto-merge }}
run: gh pr merge "${{ steps.create-pull-request.outputs.pull-request-number }}" --squash --auto
env:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/workflow-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Workflow Linter

on:
pull_request:
types:
# - edited # PR's base branch was changed
- opened
- reopened
- synchronize # PR's branch was edited (i.e. new commits)

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- run: go install github.com/rhysd/actionlint/cmd/actionlint@latest
- run: actionlint

# !!! This check should be required by GitHub !!!
workflow-status-check:
if: always()
needs:
- lint
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

0 comments on commit 8b97a41

Please sign in to comment.