Skip to content

Commit 879176e

Browse files
authored
Merge pull request #71 from rocky-linux/07-29-switch_to_use_fastly_compute_actions
Update deployment workflow
2 parents 5af0cf0 + 4e94d31 commit 879176e

4 files changed

Lines changed: 178 additions & 21 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build site with mkdocs and cache / save
2+
description: Builds and deploys docs.r.o with mkdocs and caches build output
3+
outputs:
4+
DOCS_SHA:
5+
description: "DOCS_SHA"
6+
value: ${{ steps.docs-sha.outputs.DOCS_SHA }}
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Install deps
11+
run: dnf -y install python3-pip npm git-core
12+
shell: bash
13+
14+
- name: Checkout documentation repo
15+
uses: actions/checkout@v4
16+
with:
17+
repository: rocky-linux/documentation
18+
path: docs
19+
fetch-depth: 0
20+
21+
- name: set docs-sha
22+
id: docs-sha
23+
working-directory: docs
24+
run: echo "DOCS_SHA=$(git rev-parse --verify HEAD)" >> "$GITHUB_OUTPUT"
25+
shell: bash
26+
27+
- uses: actions/cache/restore@v4
28+
id: docs-cache
29+
with:
30+
path: build/site/minified
31+
key: cache-docs-${{ steps.docs-sha.outputs.DOCS_SHA }}
32+
lookup-only: true
33+
34+
- run: python3.9 -m pip install -r requirements.txt
35+
if: steps.docs-cache.outputs.cache-hit != 'true'
36+
shell: bash
37+
38+
- run: chown -R 1001:1001 .
39+
if: steps.docs-cache.outputs.cache-hit != 'true'
40+
shell: bash
41+
42+
- name: Build Site
43+
if: steps.docs-cache.outputs.cache-hit != 'true'
44+
run: npm run build
45+
shell: bash
46+
47+
- name: Save built site
48+
if: steps.docs-cache.outputs.cache-hit != 'true'
49+
id: cache-build
50+
uses: actions/cache/save@v4
51+
with:
52+
path: |
53+
build/minified/site
54+
key: cache-docs-${{ steps.docs-sha.outputs.DOCS_SHA }}
55+
56+
- name: Archive build artifacts
57+
if: steps.docs-cache.outputs.cache-hit != 'true'
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: build-minified
61+
path: |
62+
build/minified/site

.github/workflows/deploy.yml

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,63 @@ jobs:
1717
runs-on: ubuntu-latest
1818
container:
1919
image: quay.io/rockylinux/rockylinux:9
20+
options: --user root
21+
outputs:
22+
DOCS_SHA: ${{steps.build.outputs.DOCS_SHA}}
2023
environment: production
2124
steps:
22-
- name: Install deps
23-
run: dnf -y install python3-pip npm git-core
24-
- uses: actions/checkout@v4
25-
- uses: actions/checkout@v4
25+
- name: Checkout mkdocs config
26+
uses: actions/checkout@v4
27+
28+
- name: "Build Site"
29+
uses: ./.github/actions/build-and-cache/
30+
31+
- name: set docs-sha
32+
id: docs-sha
33+
run: echo "$DOCS_SHA" >> "$GITHUB_OUTPUT"
34+
deploy:
35+
name: deploy
36+
needs: build
37+
runs-on: ubuntu-latest
38+
environment: production
39+
steps:
40+
41+
- uses: actions/cache/restore@v4
42+
id: docs-cache
2643
with:
27-
repository: rocky-linux/documentation
28-
path: docs
29-
- run: python3.9 -m pip install -r requirements.txt
30-
- name: Build Site
31-
run: npm run build
32-
- name: Archive build artifacts
33-
uses: actions/upload-artifact@v4
44+
path: build/site/minified
45+
key: cache-docs-${{ needs.build.outputs.DOCS_SHA }}
46+
fail-on-cache-miss: false
47+
enableCrossOsArchive: true
48+
49+
- name: Retrieve build artifacts
50+
if: steps.docs-cache.outputs.cache-hit != 'true'
51+
uses: actions/download-artifact@v4
3452
with:
3553
name: build-minified
3654
path: |
3755
build/minified/site
38-
- name: Deploy
56+
57+
- name: Set up Fastly CLI
58+
uses: fastly/compute-actions/setup@v6
59+
with:
60+
cli_version: 'latest'
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Install Dependencies
64+
run: npm install
65+
working-directory: ./compute-js
66+
67+
- name: Build Compute Package
68+
uses: fastly/compute-actions/build@v6
69+
with:
70+
verbose: true
71+
project_directory: compute-js
72+
73+
- name: Deploy Compute Package
74+
uses: fastly/compute-actions/deploy@v6
75+
with:
76+
comment: 'Deployed via GitHub Actions'
77+
project_directory: compute-js
3978
env:
4079
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
41-
FASTLY_SERVICE_ID: ${{ secrets.FASTLY_SERVICE_ID }}
42-
run: npm run deploy

.github/workflows/preview.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Fastly Compute Branch Previews
3+
4+
concurrency:
5+
group: ${{ github.head_ref || github.run_id }}-${{ github.workflow}}
6+
7+
on:
8+
pull_request:
9+
types: [opened, synchronize, reopened, closed]
10+
11+
jobs:
12+
build:
13+
name: build
14+
runs-on: ubuntu-latest
15+
container:
16+
image: quay.io/rockylinux/rockylinux:9
17+
options: --user root
18+
environment: preview
19+
outputs:
20+
DOCS_SHA: ${{steps.build.outputs.DOCS_SHA}}
21+
steps:
22+
23+
- name: Checkout mkdocs config
24+
uses: actions/checkout@v4
25+
26+
- name: "Build Site"
27+
id: build
28+
uses: ./.github/actions/build-and-cache/
29+
30+
- name: set docs-sha
31+
id: docs-sha
32+
run: echo "$DOCS_SHA" >> "$GITHUB_OUTPUT"
33+
34+
preview:
35+
name: preview
36+
needs: build
37+
runs-on: ubuntu-latest
38+
environment: preview
39+
defaults:
40+
run:
41+
shell: bash
42+
steps:
43+
- uses: actions/checkout@v4
44+
- run: ls -la
45+
- uses: actions/cache/restore@v4
46+
id: docs-cache
47+
with:
48+
path: build/site/minified
49+
key: cache-docs-${{ needs.build.outputs.DOCS_SHA }}
50+
fail-on-cache-miss: false
51+
enableCrossOsArchive: true
52+
- name: Retrieve build artifacts
53+
if: steps.docs-cache.outputs.cache-hit != 'true'
54+
uses: actions/download-artifact@v4
55+
with:
56+
name: build-minified
57+
path: |
58+
build/minified/site
59+
- run: ls -la
60+
- uses: neil-forks/compute-actions/preview@preview-with-subdir
61+
with:
62+
fastly-api-token: ${{ secrets.FASTLY_API_TOKEN }}
63+
github-token: ${{ secrets.GITHUB_TOKEN }}
64+
project_directory: ./compute-js

setup-deps.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ pip install -r requirements.txt
1515
# pip install "git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git"
1616
# fi
1717

18-
test -d compute-js/bin || mkdir compute-js/bin
19-
test -x compute-js/bin/fastly || ( curl -L https://github.com/fastly/cli/releases/download/v10.12.3/fastly_v10.12.3_linux-amd64.tar.gz | tar -xzf /dev/stdin -C compute-js/bin/ )
20-
2118
# mkdocs optimize plugin requires pngquant
2219
npm install pngquant
2320

2421
# minify for reducing deployment size
22+
mkdir -p compute-js/bin
2523
test -x compute-js/bin/minify || (curl -L https://github.com/tdewolff/minify/releases/download/v2.20.18/minify_linux_amd64.tar.gz | tar -C compute-js/bin/ -xz minify)
26-
27-
# jq (for yq)
28-
test -x compute-js/bin/jq || curl -L https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64 -o compute-js/bin/jq
29-
chmod +x compute-js/bin/jq

0 commit comments

Comments
 (0)