-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (130 loc) · 4.56 KB
/
prod-deploy.yml
File metadata and controls
136 lines (130 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Simple workflow for deploying mkdocs site
name: Deploy MkDocs to Production Environment
env:
deploy-target: factually-settled-boxer
deployment-url: http://factually-settled-boxer.s3-website.us-east-1.amazonaws.com
# only one Production Deploy workflow at a time
concurrency:
group: Production-Deploy
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to deploy'
required: true
type: string
env-vars:
description: 'Environment Variables to load'
required: true
type: choice
options:
- prod
- dev
enable-dry-run:
description: '--dryrun sync to target'
default: false
required: true
type: boolean
enable-size-only-run:
description: '--size-only sync to target'
default: false
required: true
type: boolean
enable-quiet-run:
description: '--quiet sync to target'
default: false
required: true
type: boolean
# These permissions are needed to interact with GitHub's OIDC Token endpoint.
permissions:
id-token: write
contents: read
jobs:
report-inputs:
runs-on: ubuntu-latest
steps:
- name: Report Inputs
run: |
export MESSAGE="tag=${{ inputs.tag }}, env-vars=${{ inputs.env-vars }}, enable-dry-run=${{ inputs.enable-dry-run }}, enable-size-only-run=${{ inputs.enable-size-only-run }}, enable-quiet-run=${{ inputs.enable-quiet-run }}"
echo "::notice title=Worfklow Inputs::$MESSAGE"
check-out-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
call-metadata-workflow:
needs: [check-out-tag]
uses: ./.github/workflows/meta.yml
secrets: inherit
build-mkdocs:
needs: [check-out-tag, call-metadata-workflow]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- name: Install Buildenv
uses: ntno/setup-buildenv@v1
- name: Build MkDocs
uses: ntno/build-mkdocs-composite-action@v5
with:
archive-enabled: true
version: ${{ inputs.tag }}/${{ inputs.env-vars }}
env-name: ${{ inputs.env-vars }}
aws-region: us-east-1
role-to-assume: ${{ secrets.PRODUCTION_IAM_ROLE_ARN }}
- name: Report Result
run: |
export MESSAGE="${{ inputs.tag }}/${{ inputs.env-vars }} built with ${{ needs.call-metadata-workflow.outputs.build-tag }}"
echo "::notice title=Built MkDocs::$MESSAGE"
deploy-mkdocs:
needs: [call-metadata-workflow, build-mkdocs]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.tag }}
- name: Install Buildenv
uses: ntno/setup-buildenv@v1
- name: Set Vars
id: set-vars
run: |
if [[ "${{ inputs.enable-dry-run }}" == "true" ]]; then
export DRY_RUN="DRY_RUN=1"
else
export DRY_RUN="DRY_RUN=0"
fi
if [[ "${{ inputs.enable-size-only-run }}" == "true" ]]; then
export SIZE_ONLY_RUN="SIZE_ONLY_SYNC=1"
else
export SIZE_ONLY_RUN="SIZE_ONLY_SYNC=0"
fi
if [[ "${{ inputs.enable-quiet-run }}" == "true" ]]; then
export QUIET_RUN="QUIET=1"
else
export QUIET_RUN="QUIET=0"
fi
echo "deploy-flags=${DRY_RUN} ${SIZE_ONLY_RUN} ${QUIET_RUN}" >> $GITHUB_OUTPUT
- name: Deploy MkDocs
id: deploy-mkdocs
uses: ntno/deploy-mkdocs-composite-action@v3
with:
version: ${{ inputs.tag }}/${{ inputs.env-vars }}
env-name: ${{ inputs.env-vars }}
s3-bucket: ${{ env.deploy-target }}
aws-region: us-east-1
make-vars-for-deploy-target: ${{ steps.set-vars.outputs.deploy-flags }}
role-to-assume: ${{ secrets.PRODUCTION_IAM_ROLE_ARN }}
- name: Report Result
run: |
if [[ "${{ inputs.enable-dry-run }}" == "true" ]]; then
export MESSAGE="Deploy is disabled for current workflow run, deployment skipped..."
echo "::notice title=Deployment Skipped::$MESSAGE"
else
export MESSAGE="${{ inputs.tag }}/${{ inputs.env-vars }} deployed to ${{ env.deployment-url }} with ${{ needs.call-metadata-workflow.outputs.build-tag }}"
echo "::notice title=Deployment Complete::$MESSAGE"
fi