Skip to content

Commit

Permalink
Merge pull request #5 from skrysmanski/feature/store-build-artifacts
Browse files Browse the repository at this point in the history
Store generated files an workflow artifacts
  • Loading branch information
skrysmanski authored Feb 12, 2024
2 parents 727c34e + 1ab68bf commit f0958db
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

- name: Download node modules
run: npm install
working-directory: themes/devlog-theme/assets
Expand All @@ -88,6 +94,30 @@ 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.
#
# 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 }}_hugo-${{ steps.hugo-version.outputs.version }}'
path: ./public/
if-no-files-found: error

# See: https://github.com/marketplace/actions/ftp-deploy
- name: Deploy site
uses: SamKirkland/[email protected]
Expand Down

0 comments on commit f0958db

Please sign in to comment.