From 6192ffed755c87269051771addb5040c0ab7d227 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Mon, 20 Nov 2023 07:55:58 -0800 Subject: [PATCH 1/2] ci: use output parameter for MADE_CHANGES check Previously, this was using outdated and 'insecure' syntax for setting an environment variable. More info here: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/ This could have been solved by using `echo STUFF >> "$GITHUB_ENV"` but I think using a step output is even better, mainly because it's more clear what kind of changes `MADE_CHANGES` is talking about. I also reordered the commands so that if writing the step output fails, the step will fail before pushing the changes. That means we'll no longer end up with half-released changes (released on GitHub but not NPM). --- .github/workflows/daily-tx-pull.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/daily-tx-pull.yml b/.github/workflows/daily-tx-pull.yml index 380e2264..b1e482bb 100644 --- a/.github/workflows/daily-tx-pull.yml +++ b/.github/workflows/daily-tx-pull.yml @@ -41,18 +41,19 @@ jobs: npm run test - name: Commit translation updates + id: commit run: | git config --global user.email $(git log --pretty=format:"%ae" -n1) git config --global user.name $(git log --pretty=format:"%an" -n1) git add . if git diff --cached --exit-code --quiet; then + echo "MADE_CHANGES=false" >> "$GITHUB_OUTPUT" echo "Nothing to commit." - echo "::set-env name=MADE_CHANGES::false" else git commit -m "pull new editor translations from Transifex" + echo "MADE_CHANGES=true" >> "$GITHUB_OUTPUT" git push origin HEAD:master - echo "::set-env name=MADE_CHANGES::true" fi - name: Start CI/CD workflow if changes were made - if: env.MADE_CHANGES == 'true' + if: steps.commit.outputs.MADE_CHANGES == 'true' uses: ./.github/workflows/ci-cd.yml From 62f23e8dabd77eaad84e888877627e6a18170c90 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Mon, 20 Nov 2023 08:10:57 -0800 Subject: [PATCH 2/2] ci: run commitlint action on PRs only --- .github/workflows/ci-cd.yml | 3 +-- .github/workflows/commitlint.yml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/commitlint.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 062cbd20..0f32e345 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -22,8 +22,7 @@ jobs: TRIGGER_DEPLOY: ${{ startsWith(github.ref, 'refs/heads/master') }} steps: - uses: actions/checkout@v4 - - uses: wagoid/commitlint-github-action@v5 - if: github.event_name == 'pull_request' + - uses: actions/setup-node@v3 with: cache: "npm" diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml new file mode 100644 index 00000000..68298687 --- /dev/null +++ b/.github/workflows/commitlint.yml @@ -0,0 +1,13 @@ +name: Lint commit messages +on: [pull_request] + +concurrency: + group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: wagoid/commitlint-github-action@v5