From e4c2c7a33600af196887f6b086ce7bac1caa8941 Mon Sep 17 00:00:00 2001 From: Sebastian Krysmanski Date: Sat, 10 Feb 2024 06:16:09 +0100 Subject: [PATCH] Store generated files in workflow artifact --- .github/workflows/build-and-deploy.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/build-and-deploy.yaml index 41637a5..29ba1bc 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,21 @@ jobs: run: npx pagefind --site "../../../public" working-directory: themes/devlog-theme/assets + # See: https://github.com/actions/upload-artifact + # NOTE: Artifacts are retained only up to 90 days at the moment. See: https://github.com/orgs/community/discussions/107115 + - 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 }}-${{ 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