Skip to content

Commit fea4c0b

Browse files
authored
Merge pull request #1375 from nirmalsunny/main
Deploy both Internal and Production website to S3 and serve using CloudFront
2 parents 7a8c687 + 040c5bb commit fea4c0b

File tree

6 files changed

+199
-98
lines changed

6 files changed

+199
-98
lines changed

.github/workflows/deploy.yml

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,66 @@
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+
target:
7+
description: "Hugo target to deploy to"
8+
required: true
9+
type: string
10+
aws-region:
11+
description: "AWS Region to use for fetching credentials"
12+
required: false
13+
type: string
14+
default: "us-west-2"
15+
secrets:
16+
AWS_OIDC_ROLE:
17+
required: true
18+
HUGO_LLM_API:
19+
required: true
20+
21+
env:
22+
HUGO_VERSION: 0.130.0
1223

13-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1424
jobs:
15-
# This workflow contains a single job called "build"
1625
build_and_deploy:
1726
# The type of runner that the job will run on
1827
runs-on: ubuntu-latest
19-
20-
# Steps represent a sequence of tasks that will be executed as part of the job
28+
permissions:
29+
id-token: write
30+
contents: read
2131
steps:
22-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
2333
- uses: actions/checkout@v4
2434
with:
25-
submodules: true # Fetch Hugo Themes
26-
fetch-depth: 0
35+
submodules: true # Fetch Hugo Themes
36+
fetch-depth: 0
2737

2838
# Sets Up Hugo
2939
- name: Setup Hugo
3040
uses: peaceiris/actions-hugo@v3
3141
with:
32-
hugo-version: '0.130.0'
33-
extended: true
34-
35-
# Post-CSS install
42+
hugo-version: ${{ env.HUGO_VERSION }}
43+
extended: true
44+
45+
# Installs Post-CSS
3646
- name: Install Post-CSS
3747
run: npm install postcss-cli
3848

39-
# Builds arm-learning-paths repo
49+
- name: AWS Github OIDC Login
50+
uses: aws-actions/configure-aws-credentials@v4
51+
with:
52+
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
53+
aws-region: ${{ inputs.aws-region }}
54+
55+
# Builds arm-software-developer repo
4056
- name: Build
4157
run: |
4258
hugo --minify
4359
cp learn-image-sitemap.xml public/learn-image-sitemap.xml
4460
bin/pagefind --site "public"
4561
env:
4662
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}}
63+
64+
# Deploys website to AWS S3 and invalidate CloudFront Cache
65+
- name: Deploy to S3
66+
run: hugo deploy --force --maxDeletes -1 --invalidateCDN --target ${{ inputs.target }}

.github/workflows/main.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,63 @@
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:
14+
build_and_deploy_internal_existing:
15+
name: Build and Deploy Internal Existing
1816
# The type of runner that the job will run on
1917
runs-on: ubuntu-latest
20-
2118
# Steps represent a sequence of tasks that will be executed as part of the job
2219
steps:
2320
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2421
- uses: actions/checkout@v4
2522
with:
26-
submodules: true # Fetch Hugo Themes
27-
fetch-depth: 0
23+
submodules: true # Fetch Hugo Themes
24+
fetch-depth: 0
2825

2926
# Sets Up Hugo
3027
- name: Setup Hugo
3128
uses: peaceiris/actions-hugo@v3
3229
with:
33-
hugo-version: '0.130.0'
34-
extended: true
35-
30+
hugo-version: "0.130.0"
31+
extended: true
32+
3633
# Post-CSS install and Node.js
3734
- name: Install Post-CSS
3835
run: npm install postcss-cli
3936

40-
4137
# Builds arm-software-developer repo
4238
- name: Build
4339
run: |
4440
hugo --minify
4541
cp learn-image-sitemap.xml public/learn-image-sitemap.xml
4642
bin/pagefind --site "public"
4743
env:
48-
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}
44+
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}
4945

5046
# Deploys website to AWS S3
5147
- name: Deploy to S3
52-
run: hugo deploy --force --maxDeletes -1 --invalidateCDN
48+
run: hugo deploy --force --maxDeletes -1 --invalidateCDN --target internal-existing
5349
env:
54-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
55-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
56-
50+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
51+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
52+
53+
build_and_deploy_internal:
54+
name: Build and Deploy Internal
55+
uses: ./.github/workflows/deploy.yml
56+
permissions:
57+
id-token: write
58+
contents: read
59+
with:
60+
target: internal
61+
secrets:
62+
AWS_OIDC_ROLE: ${{ secrets.AWS_OIDC_ROLE_INTERNAL }}
63+
HUGO_LLM_API: ${{ secrets.HUGO_LLM_API }}

.github/workflows/production.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
target: production
77+
secrets:
78+
AWS_OIDC_ROLE: ${{ secrets.AWS_OIDC_ROLE_PRODUCTION }}
79+
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)