Skip to content

chore: update github actions #39

chore: update github actions

chore: update github actions #39

Workflow file for this run

name: CI
on:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PANDOC_VERSION: '3.8.3'
VERCEL_VERSION: '50.1.6'
WEB_MD_PATH: 'profile/README.md'
PANDOC_FILTER: 'web/pandoc/filters/year.lua'
PANDOC_TEMPLATE: 'web/pandoc/templates/alchemax.html'
jobs:
install-pandoc:
runs-on: ubuntu-latest
steps:
- name: Restore Pandoc cache
id: cache-pandoc
uses: actions/cache@v6
with:
path: /home/runner/pandoc
key: ${{ runner.os }}-pandoc-${{ env.PANDOC_VERSION }}
- name: Install Pandoc
if: steps.cache-pandoc.outputs.cache-hit != 'true'
run: |
echo "Installing Pandoc..."
mkdir -p /home/runner/pandoc
cd /home/runner/pandoc
wget https://github.com/jgm/pandoc/releases/download/${{ env.PANDOC_VERSION }}/pandoc-${{ env.PANDOC_VERSION }}-linux-amd64.tar.gz
tar xvzf pandoc-${{ env.PANDOC_VERSION }}-linux-amd64.tar.gz --strip-components 1
rm pandoc-${{ env.PANDOC_VERSION }}-linux-amd64.tar.gz
install-vercel-cli:
runs-on: ubuntu-latest
steps:
- name: Restore Vercel CLI cache
id: cache-vercel
uses: actions/cache@v6
with:
path: /home/runner/npm-global-vercel
key: ${{ runner.os }}-vercel-${{ env.VERCEL_VERSION }}
- name: Install Vercel CLI
if: steps.cache-vercel.outputs.cache-hit != 'true'
run: |
echo "Installing Vercel CLI..."
npm config set prefix /home/runner/npm-global-vercel
npm install -g vercel@${{ env.VERCEL_VERSION }}
generate_html:
runs-on: ubuntu-latest
needs: [install-pandoc]
steps:
- name: Checkout code (shallow)
uses: actions/checkout@v7
- name: Restore Pandoc cache
uses: actions/cache@v6
with:
path: /home/runner/pandoc
key: ${{ runner.os }}-pandoc-${{ env.PANDOC_VERSION }}
- name: Add Pandoc to PATH
run: echo "/home/runner/pandoc/bin" >> $GITHUB_PATH
- name: Convert README to HTML
run: pandoc -s --lua-filter=${{ env.PANDOC_FILTER }} --template=${{ env.PANDOC_TEMPLATE }} ${{ env.WEB_MD_PATH }} -o index.html
- name: Upload HTML artifact
uses: actions/upload-artifact@v7
with:
name: generated-html
path: index.html
deploy_prod:
runs-on: ubuntu-latest
needs: [install-vercel-cli, generate_html]
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code (for vercel.json and static assets)
uses: actions/checkout@v7
- name: Download HTML artifact
uses: actions/download-artifact@v8
with:
name: generated-html
- name: Restore Vercel CLI cache
uses: actions/cache@v6
with:
path: /home/runner/npm-global-vercel
key: ${{ runner.os }}-vercel-${{ env.VERCEL_VERSION }}
- name: Add Vercel CLI to PATH
run: echo "/home/runner/npm-global-vercel/bin" >> $GITHUB_PATH
- name: Deploy to Vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
vercel link \
--token $VERCEL_TOKEN \
--project alchemax-website \
--yes
vercel deploy \
--prod \
--token=$VERCEL_TOKEN \
--yes
ci-passed:
name: CI Passed
runs-on: ubuntu-latest
if: always()
needs: [install-pandoc, install-vercel-cli, generate_html, deploy_prod]
steps:
- name: Verify all jobs passed or were skipped
run: |
results=(
"${{ needs.install-pandoc.result }}"
"${{ needs.install-vercel-cli.result }}"
"${{ needs.generate_html.result }}"
"${{ needs.deploy_prod.result }}"
)
for result in "${results[@]}"; do
if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then
echo "Job failed or was cancelled: $result"
exit 1
fi
done
echo "All jobs passed or were skipped"