Skip to content

Commit ee0685b

Browse files
authored
Merge pull request #48 from uli-f/publish-to-github-pages-workflow
add CI pipeline and deploy workflow for GitHub Pages
2 parents d2ee246 + 2bb0d83 commit ee0685b

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI Pipeline
2+
# Produces production artifact, uploads it as workflow artifact
3+
4+
on:
5+
push:
6+
branches: [source]
7+
paths-ignore:
8+
- '**.md'
9+
10+
pull_request:
11+
branches: [source]
12+
paths-ignore:
13+
- '**.md'
14+
15+
# allows this workflow to be run from another
16+
workflow_call:
17+
18+
# allows running this workflow manually from the Actions tab
19+
workflow_dispatch:
20+
21+
jobs:
22+
build:
23+
name: Build
24+
runs-on: 'ubuntu-22.04'
25+
steps:
26+
- name: 🛫 Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
persist-credentials: false
30+
31+
- name: 🧶 Setup Node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version-file: 'package.json'
35+
cache: 'npm'
36+
37+
- name: 👩‍🔧 Install dependencies
38+
run: npm clean-install
39+
40+
- name: 📦 Build for production
41+
id: build_step
42+
run: npm run production 2>&1 | tee build-output.log
43+
44+
- name: 📤 Upload Pages artifact
45+
uses: actions/upload-pages-artifact@v3
46+
# only run if on source branch or on a tag
47+
if: ${{ github.ref == 'refs/heads/source' || startsWith( github.ref, 'refs/tags/' )}}
48+
with:
49+
path: dist/
50+
51+
- name: 📝 Generate workflow summary
52+
run: |
53+
echo "### 📦 Webpack Build Summary" >> $GITHUB_STEP_SUMMARY
54+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
55+
sed -r "s/\x1B\[[0-9;]*[mK]//g" build-output.log >> $GITHUB_STEP_SUMMARY
56+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

.github/workflows/deploy.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
release:
5+
types: [ 'published' ]
6+
7+
# allows running this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read # required for git checkout
12+
pages: write # to deploy to GitHub Pages
13+
id-token: write # to verify the deployment originates from an appropriate source
14+
actions: write # required to write a job summary
15+
16+
jobs:
17+
ci:
18+
name: 🚀 CI
19+
uses: ./.github/workflows/ci.yaml
20+
permissions:
21+
contents: read
22+
actions: write # required to write a job summary
23+
24+
# Deploys Pages artifact to GitHub Pages.
25+
deploy-pages-artifact:
26+
name: Deploy Pages Artifact to GitHub Pages
27+
needs: ci
28+
# Deploy to github-pages environment
29+
environment:
30+
name: github-pages
31+
url: ${{ steps.deployment.outputs.page_url }}
32+
runs-on: 'ubuntu-24.04'
33+
steps:
34+
# Deploy the artifact from the 'ci' job
35+
- name: 🚀 Deploy to GitHub Pages
36+
id: deployment
37+
uses: actions/deploy-pages@v4
38+
39+
- name: 📝 Generate deployment summary
40+
run: |
41+
echo "### 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY
42+
echo "Website deployed to: ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)