From 5a81919cf2350d4f0c08f7d6ab40fe3b76a42c4e Mon Sep 17 00:00:00 2001 From: c3n21 Date: Mon, 14 Jul 2025 20:31:28 +0200 Subject: [PATCH 1/9] feat: add gh, act --- .gitignore | 3 --- README.md | 10 ++++++++++ flake.nix | 4 ++++ scripts/sh/test-workflow.sh | 1 + 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 scripts/sh/test-workflow.sh diff --git a/.gitignore b/.gitignore index 59918f1..6d4c0aa 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,3 @@ pnpm-debug.log* # macOS-specific files .DS_Store - -# temporary CV file (created during deployment) -src/cv.json diff --git a/README.md b/README.md index 8ed1818..769ba58 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,13 @@ To actually do the deploy of the website and CV in release artifacts the followi 1. Create a PR which only bumps the version in package.json 2. By merging the PR it will trigger `release.yml` which in turn triggers `deploy.yml`. + +# Test workflows locally +1. Install `act`, `gh` +2. Login in `gh` with `gh auth login` +3. Put manually `src/cv.json` +4. Comment `Write src/cv.json from input` step in `.github/actions/build-with-cv/action.yml` +5. Run `sh ./scripts/sh/test-workflow.sh ` + +Caveats: +I've tested only `build-web` job which works properly, other workflows/jobs are not tested / are failing. diff --git a/flake.nix b/flake.nix index 9da6cc9..065af7e 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,10 @@ [ nodejs_22 # Specify Node.js version pnpm + + # GitHub action local testing + act + gh ] ++ (with nvim-pkgs; [ nastro ]); diff --git a/scripts/sh/test-workflow.sh b/scripts/sh/test-workflow.sh new file mode 100644 index 0000000..f5fb319 --- /dev/null +++ b/scripts/sh/test-workflow.sh @@ -0,0 +1 @@ +act workflow_dispatch --artifact-server-path $PWD/.artifacts -s GITHUB_TOKEN="$(gh auth token)" --use-new-action-cache -W "$1" From fbe69f587f179f4766bc281aea119fa491261984 Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 08:00:24 +0200 Subject: [PATCH 2/9] release-test (to be reverted) --- .github/workflows/deploy.yml | 1 + .github/workflows/release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 90aa3e3..4063f24 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,7 @@ on: push: branches: - main + - release-test release: types: [created] workflow_dispatch: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0290f09..7a51c1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - release-test # for debugging purpose workflow_dispatch: From cf4ae4e32f22ddb3e37ce18d87ab3b67cfa90268 Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 08:12:04 +0200 Subject: [PATCH 3/9] remove useless if --- .github/workflows/deploy.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4063f24..2cb9163 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,10 +27,6 @@ permissions: jobs: build-web: - if: > - (github.event_name == 'release' && github.event.action == 'created' ) || - (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main')) || - (github.event_name == 'workflow_dispatch') runs-on: ubuntu-latest outputs: neovim-lines: ${{ steps.lines.outputs.count }} @@ -67,10 +63,6 @@ jobs: path: ./dist/ build-cv: - if: > - (github.event_name == 'release' && github.event.action == 'created' ) || - (github.event_name == 'push' && startsWith(github.ref, 'refs/heads/main')) || - (github.event_name == 'workflow_dispatch') needs: build-web # leverage pnpm cache reuse runs-on: ubuntu-latest env: From a0b40725273839806b358d2afcffea4b301948bf Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 08:38:19 +0200 Subject: [PATCH 4/9] feat(workflows/deploy): use sha for concurrency group --- .github/workflows/deploy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2cb9163..da06060 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,9 +15,11 @@ on: workflow_dispatch: # Cancel any previous workflow. -# This can happen when we merge a PR that triggers a new release +# This can happen when we merge a PR that triggers a new release. +# The concurrency group uses the workflow name and the sha of the commit, so that +# we don't need to care whether it's a release or not. concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ${{ github.workflow }}-${{ github.sha }} cancel-in-progress: true permissions: From 30e5682504e6468301465cdfbf2e3969a36baf0b Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 11:19:38 +0200 Subject: [PATCH 5/9] debug ref_name --- .github/workflows/deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index da06060..a47128f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,6 +33,10 @@ jobs: outputs: neovim-lines: ${{ steps.lines.outputs.count }} steps: + - name: Initial + run: | + echo "${{ github.ref_name }}" + - uses: actions/checkout@v4 - name: Checkout NeoVim config From 3982efab08a086969802dbb9b40521f83e1a0da5 Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 11:47:20 +0200 Subject: [PATCH 6/9] fix: artifact download --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a47128f..9024bcf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -115,7 +115,7 @@ jobs: uses: actions/download-artifact@v4 with: name: cv - path: ./cv.pdf + path: . - name: Upload PDF as Release Asset uses: softprops/action-gh-release@v2 From 449db0cec6950ca5c223fa672139fd6a098e38ae Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 12:01:51 +0200 Subject: [PATCH 7/9] fix(workflows/deploy): run on release publish --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9024bcf..5adaaa7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,7 +11,7 @@ on: - main - release-test release: - types: [created] + types: [ published unpublished created edited deleted prereleased released ] workflow_dispatch: # Cancel any previous workflow. From 203eea7559139a43d244132c1d1735238752f6e7 Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 12:12:21 +0200 Subject: [PATCH 8/9] use gh cli to create release --- .github/workflows/release.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a51c1b..7f7d1c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,18 +18,21 @@ jobs: - name: Checkout repo uses: actions/checkout@v4 - - name: Read version from package.json + - name: Create release id: get_version + env: + GH_TOKEN: ${{ github.token }} run: | version=$(jq -r '.version' package.json) echo "version=$version" >> $GITHUB_OUTPUT + gh release create "$version" --title "$version" --notes "" - - name: Create release tag and GitHub Release - uses: softprops/action-gh-release@v2 - with: - tag_name: "v${{ steps.get_version.outputs.version }}" - name: "Release v${{ steps.get_version.outputs.version }}" - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - name: Create release tag and GitHub Release + # uses: softprops/action-gh-release@v2 + # with: + # tag_name: "v${{ steps.get_version.outputs.version }}" + # name: "Release v${{ steps.get_version.outputs.version }}" + # draft: false + # prerelease: false + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0d07c88784406d35ec36d769cca1f5cb8013d217 Mon Sep 17 00:00:00 2001 From: c3n21 Date: Tue, 15 Jul 2025 15:58:59 +0200 Subject: [PATCH 9/9] simplify workflows --- .github/workflows/deploy.yml | 9 --------- .github/workflows/release.yml | 38 ----------------------------------- 2 files changed, 47 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5adaaa7..94fafbd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,9 +9,6 @@ on: push: branches: - main - - release-test - release: - types: [ published unpublished created edited deleted prereleased released ] workflow_dispatch: # Cancel any previous workflow. @@ -33,10 +30,6 @@ jobs: outputs: neovim-lines: ${{ steps.lines.outputs.count }} steps: - - name: Initial - run: | - echo "${{ github.ref_name }}" - - uses: actions/checkout@v4 - name: Checkout NeoVim config @@ -104,7 +97,6 @@ jobs: path: ./cv.pdf deploy-cv: - if: github.event_name == 'release' && github.event.action == 'created' || github.event_name == 'workflow_dispatch' needs: build-cv runs-on: ubuntu-latest env: @@ -127,7 +119,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} deploy-web: - if: github.event_name == 'release' && github.event.action == 'created' || github.event_name == 'workflow_dispatch' needs: build-web runs-on: ubuntu-latest environment: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7f7d1c7..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Auto Release on Version Bump - -on: - push: - branches: - - main - - release-test - # for debugging purpose - workflow_dispatch: - -permissions: - contents: write - -jobs: - create-release: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Create release - id: get_version - env: - GH_TOKEN: ${{ github.token }} - run: | - version=$(jq -r '.version' package.json) - echo "version=$version" >> $GITHUB_OUTPUT - gh release create "$version" --title "$version" --notes "" - - # - name: Create release tag and GitHub Release - # uses: softprops/action-gh-release@v2 - # with: - # tag_name: "v${{ steps.get_version.outputs.version }}" - # name: "Release v${{ steps.get_version.outputs.version }}" - # draft: false - # prerelease: false - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}