From 47184118d443f7c9a7c0a15014aed94034f58ba3 Mon Sep 17 00:00:00 2001 From: Sebastian Krysmanski Date: Sat, 10 Feb 2024 06:16:09 +0100 Subject: [PATCH 1/2] Store generated files in workflow artifact --- .github/workflows/build-and-deploy.yaml | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/build-and-deploy.yaml index 41637a5..4ed0b47 100644 --- a/.github/workflows/build-and-deploy.yaml +++ b/.github/workflows/build-and-deploy.yaml @@ -68,6 +68,12 @@ jobs: # IMPORTANT: Fetch the whole history. This is how Hugo determines the (publish) dates for the articles!!! fetch-depth: 0 + # This creates ${{ steps.short-sha.outputs.sha }} to be used below. + # See: https://github.com/marketplace/actions/short-sha + - name: Provide short commit hash to workflow + id: short-sha + uses: benjlevesque/short-sha@v3.0 + - name: Download node modules run: npm install working-directory: themes/devlog-theme/assets @@ -88,6 +94,26 @@ jobs: run: npx pagefind --site "../../../public" working-directory: themes/devlog-theme/assets + # + # Store generated files in a zip file in the workflow itself. This way outputs between two workflow runs can be compared, + # if necessary. + # + # NOTE: Artifacts are retained only up to 90 days at the moment. See: https://github.com/orgs/community/discussions/107115 + # + # See: https://github.com/actions/upload-artifact + - name: Add generated files to workflow run + uses: actions/upload-artifact@v4 + with: + # To make the artifacts easier to differentiate (i.e. when downloading them from different runs), + # we'll add the workflow run number to the name (this is the same number that's also shown in the + # GitHub UI - like 27 for run #27). + # + # NOTE: We also add some context information (like the commit SHA) to the file name to make it easier + # to identify what this artifact represents. + name: 'generated-files_#${{ github.run_number }}_sha-${{ steps.short-sha.outputs.sha }}' + path: ./public/ + if-no-files-found: error + # See: https://github.com/marketplace/actions/ftp-deploy - name: Deploy site uses: SamKirkland/FTP-Deploy-Action@v4.3.4 From 1ab68bfe7052517ced7867c1b7f4eff7b72fc7ec Mon Sep 17 00:00:00 2001 From: Sebastian Krysmanski Date: Mon, 12 Feb 2024 16:21:53 +0100 Subject: [PATCH 2/2] Add hugo version to artifact name --- .github/workflows/build-and-deploy.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/build-and-deploy.yaml index 4ed0b47..fbbfa8d 100644 --- a/.github/workflows/build-and-deploy.yaml +++ b/.github/workflows/build-and-deploy.yaml @@ -94,6 +94,10 @@ jobs: run: npx pagefind --site "../../../public" working-directory: themes/devlog-theme/assets + - name: Determine Hugo version + id: hugo-version + run: hugo version | sed -r 's/hugo v([0-9.]+).*/version=\1/' >> $GITHUB_OUTPUT + # # Store generated files in a zip file in the workflow itself. This way outputs between two workflow runs can be compared, # if necessary. @@ -110,7 +114,7 @@ jobs: # # NOTE: We also add some context information (like the commit SHA) to the file name to make it easier # to identify what this artifact represents. - name: 'generated-files_#${{ github.run_number }}_sha-${{ steps.short-sha.outputs.sha }}' + name: 'generated-files_#${{ github.run_number }}_sha-${{ steps.short-sha.outputs.sha }}_hugo-${{ steps.hugo-version.outputs.version }}' path: ./public/ if-no-files-found: error