Skip to content

vault backup: 2024-07-03T17:06:16 #110

vault backup: 2024-07-03T17:06:16

vault backup: 2024-07-03T17:06:16 #110

Workflow file for this run

name: Build and Deploy
on:
push:
workflow_dispatch:
concurrency:
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache .url-cache
uses: actions/cache@v4
env:
cache-name: cache-url-cache
with:
path: ./.url-cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('.url-cache') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm ci
name: Install dependencies
- name: URL Check
run: npm run check-urls
- name: Build
run: npx -y quartz build --bundleInfo
- uses: actions/upload-artifact@v4
with:
path: public
name: public
# preview:
# name: Preview when PR exists branch
# runs-on: ubuntu-latest
# needs: build
# if: github.event_name == 'pull_request' && github.event.action != 'closed'
# permissions:
# id-token: write
# pages: write
# steps:
# - name: Check out the repo
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Get artifacts from build job
# uses: actions/download-artifact@v4
# with:
# name: public
# path: public
# - uses: actions/upload-pages-artifact@v3
# with:
# path: public
# name: pages
# - name: Deploy to GitHub Pages
# uses: actions/deploy-pages@v4
# with:
# artifact_name: pages
# preview: true
deploy:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
pages: write
contents: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get git commit hash
id: get_commit_hash
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Get the ISO timestamp of the latest commit
id: get_timestamp
run: echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=format:'%cI')" >> $GITHUB_ENV
- name: Make tag name from timestamp
id: make_tag_name
run: echo "TIMESTAMP_TAG=$(date -d $COMMIT_TIMESTAMP +%Y/%m/%d/%H%M%S)" >> $GITHUB_ENV
- name: Create and push tag on given commit
run: |
git tag $TIMESTAMP_TAG $COMMIT_HASH
git push origin $TIMESTAMP_TAG
- name: Get artifacts from build job
uses: actions/download-artifact@v4
with:
path: public
name: public
- name: List files in public
run: |
ls -lah .
ls -lah public
- name: Compress files
run: |
tar -czf pages.tar.gz public
ls -lah
- name: Make formatted release name
run: echo "RELEASE_NAME=$(date -d $COMMIT_TIMESTAMP '+%Y/%m/%d %H:%M:%S')" >> $GITHUB_ENV
- uses: actions/upload-pages-artifact@v3
with:
path: public
name: pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
artifact_name: pages
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TIMESTAMP_TAG }}
fail_on_unmatched_files: true
# target_commitish: ${{ env.COMMIT_HASH }}
generate_release_notes: true
files: pages.tar.gz