-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (115 loc) · 3.87 KB
/
publish-web-select.yml
File metadata and controls
130 lines (115 loc) · 3.87 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
name: Deploy Web to Environment
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy to'
required: true
default: 'lz-dev'
type: choice
options:
- lz-dev
- lz-test
- lz-prod
- dev
- test
- prod
branch:
description: 'Branch to deploy from'
required: true
default: 'master'
type: string
env:
WORKING_DIRECTORY: ./web
WEB_IMAGE_NAME: web
WEB_RUNTIME_IMAGE_NAME: web-runtime
WEB_ARTIFACTS_IMAGE_NAME: web-artifacts
GITHUB_IMAGE_REPO: ghcr.io/bcgov/jasper
WEB_BASE_HREF: /
jobs:
build:
name: Build, Create and Push Image
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.short_sha.outputs.SHORT_SHA }}
strategy:
matrix:
node-major-version: [22]
node-minor-version: [x]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.inputs.branch }}
- name: Building Web codebase
uses: ./.github/workflows/actions/build-web
with:
working_directory: ${{ env.WORKING_DIRECTORY }}
node_version: ${{ matrix.node-major-version }}.${{ matrix.node-minor-version }}
- name: Log in to the GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get short SHA
id: short_sha
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
with:
driver: docker
- name: Setup ${{ env.WEB_IMAGE_NAME }} Image Metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: |
${{ env.GITHUB_IMAGE_REPO }}/${{ env.WEB_IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.short_sha.outputs.SHORT_SHA }}
- name: Build ${{ env.WEB_IMAGE_NAME }} image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
push: true
context: .
file: ./docker/web/Dockerfile.release
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
NODE_VERSION=${{ matrix.node-major-version }}
WEB_BASE_HREF=${{ env.WEB_BASE_HREF }}
NGINX_RUNTIME_SRC=../../docker/nginx-runtime
VUE_ON_NGINX_SRC=../../docker/vue-on-nginx
WEB_SRC=../../web
deploy2env:
name: Deploy to ENV
needs: build
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
permissions:
id-token: write
packages: write
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.inputs.branch }}
- name: Deploy to ${{ env.ENVIRONMENT }}
uses: ./.github/workflows/actions/deploy-app
with:
environment: ${{ env.ENVIRONMENT }}
aws_account: ${{ vars.AWS_ACCOUNT }}
region: ${{ vars.AWS_REGION }}
app_name: ${{ vars.APP_NAME }}
aws_role_arn: ${{ vars.AWS_ROLE_ARN }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
github_image_repo: ${{ env.GITHUB_IMAGE_REPO }}
image_name: ${{ env.WEB_IMAGE_NAME }}
tier_name: web
short_sha: ${{ needs.build.outputs.short_sha }}