Skip to content

Commit b47d6b1

Browse files
committed
Deploy to CloudFront
Match the job name to production Update _review.md Rephrased a KC question to ensure that it is is framed as a question with a question mark.
1 parent 67bc7ee commit b47d6b1

File tree

6 files changed

+206
-125
lines changed

6 files changed

+206
-125
lines changed

.github/workflows/deploy.yml

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: Deploy Hugo to S3
22

3-
name: content-deploy
4-
5-
# Controls when the workflow will run
63
on:
7-
# Triggers the workflow on push to production branch
8-
push:
9-
branches: [ production ]
10-
# Allows you to run this workflow manually from the Actions tab
11-
workflow_dispatch:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
description: "Choose the environment"
8+
required: true
9+
type: string
10+
target:
11+
description: "Hugo target to deploy to"
12+
required: true
13+
type: string
14+
aws-region:
15+
description: "AWS Region to use for fetching credentials"
16+
required: false
17+
type: string
18+
default: "us-west-2"
19+
secrets:
20+
AWS_OIDC_ROLE:
21+
required: true
22+
HUGO_LLM_API:
23+
required: true
24+
25+
env:
26+
HUGO_VERSION: 0.130.0
1227

13-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1428
jobs:
15-
# This workflow contains a single job called "build"
1629
build_and_deploy:
1730
# The type of runner that the job will run on
1831
runs-on: ubuntu-latest
19-
20-
# Steps represent a sequence of tasks that will be executed as part of the job
32+
permissions:
33+
id-token: write
34+
contents: read
2135
steps:
22-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
36+
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
2337
- uses: actions/checkout@v4
2438
with:
25-
submodules: true # Fetch Hugo Themes
26-
fetch-depth: 0
39+
submodules: true # Fetch Hugo Themes
40+
fetch-depth: 0
2741

2842
# Sets Up Hugo
2943
- name: Setup Hugo
3044
uses: peaceiris/actions-hugo@v3
3145
with:
32-
hugo-version: '0.130.0'
33-
extended: true
34-
35-
# Post-CSS install
46+
hugo-version: ${{ env.HUGO_VERSION }}
47+
extended: true
48+
49+
# Installs Post-CSS
3650
- name: Install Post-CSS
3751
run: npm install postcss-cli
3852

39-
# Builds arm-learning-paths repo
53+
- name: AWS Github OIDC Login
54+
uses: aws-actions/configure-aws-credentials@v4
55+
with:
56+
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
57+
aws-region: ${{ inputs.aws-region }}
58+
59+
# Builds arm-software-developer repo
4060
- name: Build
4161
run: |
4262
hugo --minify
4363
cp learn-image-sitemap.xml public/learn-image-sitemap.xml
4464
bin/pagefind --site "public"
4565
env:
4666
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}
47-
48-
# Copy SSH Key
49-
- name: copy key
50-
run: |
51-
echo $SSH_KEY | xargs -n 1 > tmpkey
52-
base64 -d < tmpkey > key
53-
chmod 400 key
54-
shell: bash
55-
env:
56-
SSH_KEY: ${{secrets.SSH_KEY}}
57-
58-
# SCP Site contents to netstorage
59-
- name: copy site content
60-
run: |
61-
cd public
62-
zip -r public.zip .
63-
cd ..
64-
scp -i key -o StrictHostKeyChecking=accept-new -oHostKeyAlgorithms=+ssh-dss -r public/public.zip $USR@$HOST:/$ID/
65-
shell: bash
66-
env:
67-
USR: ${{secrets.SSH_USERNAME}}
68-
HOST: ${{secrets.SSH_HOST}}
69-
ID: ${{secrets.ID}}
67+
68+
# Deploys website to AWS S3 and invalidate CloudFront Cache
69+
- name: Deploy to S3
70+
run: hugo deploy --force --maxDeletes -1 --invalidateCDN --target ${{ inputs.target }}

.github/workflows/main.yml

Lines changed: 31 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,38 @@
1-
# This is a basic workflow to help you get started with Actions
1+
# This workflow will be triggered on a push to the 'main' branch automatically or when called manually.
2+
# Upon running this workflow, the website will be built and deployed to the internal instance.
3+
name: Build and Deploy Internal Website
24

3-
name: build-and-deploy
4-
5-
# Controls when the workflow will run
65
on:
7-
# Triggers the workflow on push or pull request events but only for the master branch
6+
# Runs on pushes to the 'main' branch
87
push:
9-
branches: [ main ]
8+
branches: [main]
109

11-
# Allows you to run this workflow manually from the Actions tab
10+
# Allows to run this workflow manually from the Actions tab
1211
workflow_dispatch:
1312

14-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1513
jobs:
16-
# This workflow contains a single job called "build"
17-
build_and_deploy_s3:
18-
# The type of runner that the job will run on
19-
runs-on: ubuntu-latest
20-
21-
# Steps represent a sequence of tasks that will be executed as part of the job
22-
steps:
23-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24-
- uses: actions/checkout@v4
25-
with:
26-
submodules: true # Fetch Hugo Themes
27-
fetch-depth: 0
28-
29-
# Sets Up Hugo
30-
- name: Setup Hugo
31-
uses: peaceiris/actions-hugo@v3
32-
with:
33-
hugo-version: '0.130.0'
34-
extended: true
35-
36-
# Post-CSS install and Node.js
37-
- name: Install Post-CSS
38-
run: npm install postcss-cli
39-
40-
41-
# Builds arm-software-developer repo
42-
- name: Build
43-
run: |
44-
hugo --minify
45-
cp learn-image-sitemap.xml public/learn-image-sitemap.xml
46-
bin/pagefind --site "public"
47-
env:
48-
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}
49-
50-
# Deploys website to AWS S3
51-
- name: Deploy to S3
52-
run: hugo deploy --force --maxDeletes -1 --invalidateCDN
53-
env:
54-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
55-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
56-
14+
build_and_deploy_internal_existing:
15+
name: Build and Deploy Internal Existing
16+
uses: ./.github/workflows/deploy.yml
17+
permissions:
18+
id-token: write
19+
contents: read
20+
with:
21+
environment: internal
22+
target: internal-existing
23+
secrets:
24+
AWS_OIDC_ROLE: ${{ secrets.AWS_OIDC_ROLE_INTERNAL }}
25+
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}
26+
27+
build_and_deploy_internal:
28+
name: Build and Deploy Internal
29+
uses: ./.github/workflows/deploy.yml
30+
permissions:
31+
id-token: write
32+
contents: read
33+
with:
34+
environment: internal
35+
target: internal
36+
secrets:
37+
AWS_OIDC_ROLE: ${{ secrets.AWS_OIDC_ROLE_INTERNAL }}
38+
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}

.github/workflows/production.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# This workflow will be triggered on a push to the 'production' branch automatically or when called manually.
2+
# Upon running this workflow, the website will be built and deployed to the production instance.
3+
name: Build and Deploy Production Website
4+
5+
on:
6+
# Runs on pushes to the 'production' branch
7+
push:
8+
branches: [production]
9+
10+
# Allows to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
jobs:
14+
build_and_deploy_existing:
15+
# The type of runner that the job will run on
16+
runs-on: ubuntu-latest
17+
18+
# Steps represent a sequence of tasks that will be executed as part of the job
19+
steps:
20+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
21+
- uses: actions/checkout@v4
22+
with:
23+
submodules: true # Fetch Hugo Themes
24+
fetch-depth: 0
25+
26+
# Sets Up Hugo
27+
- name: Setup Hugo
28+
uses: peaceiris/actions-hugo@v3
29+
with:
30+
hugo-version: "0.130.0"
31+
extended: true
32+
33+
# Post-CSS install
34+
- name: Install Post-CSS
35+
run: npm install postcss-cli
36+
37+
# Builds arm-learning-paths repo
38+
- name: Build
39+
run: |
40+
hugo --minify
41+
cp learn-image-sitemap.xml public/learn-image-sitemap.xml
42+
bin/pagefind --site "public"
43+
env:
44+
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}
45+
46+
# Copy SSH Key
47+
- name: copy key
48+
run: |
49+
echo $SSH_KEY | xargs -n 1 > tmpkey
50+
base64 -d < tmpkey > key
51+
chmod 400 key
52+
shell: bash
53+
env:
54+
SSH_KEY: ${{secrets.SSH_KEY}}
55+
56+
# SCP Site contents to netstorage
57+
- name: copy site content
58+
run: |
59+
cd public
60+
zip -r public.zip .
61+
cd ..
62+
scp -i key -o StrictHostKeyChecking=accept-new -oHostKeyAlgorithms=+ssh-dss -r public/public.zip $USR@$HOST:/$ID/
63+
shell: bash
64+
env:
65+
USR: ${{secrets.SSH_USERNAME}}
66+
HOST: ${{secrets.SSH_HOST}}
67+
ID: ${{secrets.ID}}
68+
69+
build_and_deploy_production:
70+
name: Build and Deploy Production
71+
uses: ./.github/workflows/deploy.yml
72+
permissions:
73+
id-token: write
74+
contents: read
75+
with:
76+
environment: production
77+
target: production
78+
secrets:
79+
AWS_OIDC_ROLE: ${{ secrets.AWS_OIDC_ROLE_PRODUCTION }}
80+
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}

config.toml

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,54 @@ enableRobotsTXT = true
99

1010
[deployment]
1111
[[deployment.targets]]
12-
name = "aws"
12+
name = "internal-existing"
1313
URL = "s3://armswdev.tk?region=us-east-1"
1414
cloudFrontDistributionID = "E2VDQ2CYZATMO9"
1515

16+
[[deployment.targets]]
17+
name = "internal"
18+
URL = "s3://arm-learning-paths-internal?region=us-west-2"
19+
cloudFrontDistributionID = "ENN4LK1IZUDIX"
1620

17-
21+
[[deployment.targets]]
22+
name = "production"
23+
URL = "s3://arm-learning-paths?region=us-west-2"
24+
cloudFrontDistributionID = "E2NEF61QWPFRIH"
1825

1926
[frontmatter]
20-
lastmod = [ "lastmod", ":git", "date", "publishDate" ]
27+
lastmod = ["lastmod", ":git", "date", "publishDate"]
2128

2229
[taxonomies]
23-
subject = "subjects"
24-
operatingsystem = "operatingsystems"
25-
skilllevel = "skilllevels"
26-
tool_software_language = "tools_software_languages"
27-
armip = "armips"
28-
cloud_service_provider = "cloud_service_providers"
29-
30+
subject = "subjects"
31+
operatingsystem = "operatingsystems"
32+
skilllevel = "skilllevels"
33+
tool_software_language = "tools_software_languages"
34+
armip = "armips"
35+
cloud_service_provider = "cloud_service_providers"
3036

3137
[permalinks]
32-
tools_software_languages = "/tag/:slug/"
33-
operatingsystems = "/tag/:slug/"
34-
subjects = "/tag/:slug/"
35-
cloud_service_providers = "/tag/:slug/"
36-
armips = "/tag/:slug/"
38+
tools_software_languages = "/tag/:slug/"
39+
operatingsystems = "/tag/:slug/"
40+
subjects = "/tag/:slug/"
41+
cloud_service_providers = "/tag/:slug/"
42+
armips = "/tag/:slug/"
3743

3844
[related]
39-
threshold = 0
40-
includeNewer = true
41-
toLower = false
42-
43-
[[related.indices]]
44-
name = "cloud_service_providers"
45-
weight = 100
46-
47-
[[related.indices]]
48-
name = "tools_software_languages"
49-
weight = 80
50-
51-
[[related.indices]]
52-
name = "subjects"
53-
weight = 50
45+
threshold = 0
46+
includeNewer = true
47+
toLower = false
48+
49+
[[related.indices]]
50+
name = "cloud_service_providers"
51+
weight = 100
52+
53+
[[related.indices]]
54+
name = "tools_software_languages"
55+
weight = 80
56+
57+
[[related.indices]]
58+
name = "subjects"
59+
weight = 50
5460

5561
[params]
5662
# Repository configuration (URLs for in-page links to opening issues and suggesting changes)
@@ -60,13 +66,12 @@ github_project_repo = "https://github.com/ArmDeveloperEcosystem/arm-learning-pat
6066
# location of assets
6167
assetsDir = "assets"
6268

63-
6469
# Specify a value here if your content directory is not in your repo's root directory
6570
# github_subdir = ""
6671

6772
# Uncomment this if your GitHub repo does not have "main" as the default branch,
6873
# or specify a new value if you want to reference another branch in your GitHub links
69-
github_branch= "main"
74+
github_branch = "main"
7075

7176
# For metadata posting on socials
7277
title = 'Arm Learning Paths'

content/error.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
+++
2+
title = "Request Error"
3+
description = "We are unable to serve this request at the moment."
4+
+++
5+
6+
# Request cannot be served
7+
8+
We are unable to serve this request at the moment. Try going back to our [home page](/).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{ define "main"}}
2+
<main id="main">
3+
<div>{{ .Content }}</div>
4+
</main>
5+
{{ end }}

0 commit comments

Comments
 (0)