-
Notifications
You must be signed in to change notification settings - Fork 8
78 lines (66 loc) · 2.16 KB
/
deploy.yml
File metadata and controls
78 lines (66 loc) · 2.16 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
name: Deploy Assets
on:
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/deploy.yml"
- ".gitignore"
- "deploy/**"
push:
paths:
- ".github/workflows/deploy.yml"
- ".gitignore"
- "deploy/**"
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v6
with:
go-version: "1.25.4"
cache: false
- name: Install validation tools
run: |
set -euo pipefail
python3 -m pip install --user cfn-lint
- name: Validate CloudFormation
run: |
cfn-lint deploy/aws/cloudformation/template.yaml
go test ./deploy/aws/cloudformation
publish-cloudformation:
runs-on: ubuntu-latest
needs: validate
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main'
environment: aws-publish
permissions:
contents: read
id-token: write
env:
AWS_REGION: us-east-1
CLOUDFORMATION_TEMPLATE_BUCKET: kernel-hypeman-cloudformation-prod
CLOUDFORMATION_TEMPLATE_KEY: v1/hypeman/template.yaml
CLOUDFORMATION_TEMPLATE_SOURCE: deploy/aws/cloudformation/template.yaml
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::613957054632:role/github-actions-hypeman-cloudformation-publisher
aws-region: ${{ env.AWS_REGION }}
- name: Publish CloudFormation template
run: |
set -euo pipefail
aws s3 cp \
"$CLOUDFORMATION_TEMPLATE_SOURCE" \
"s3://$CLOUDFORMATION_TEMPLATE_BUCKET/$CLOUDFORMATION_TEMPLATE_KEY" \
--content-type application/x-yaml \
--cache-control no-cache
aws s3api head-object \
--bucket "$CLOUDFORMATION_TEMPLATE_BUCKET" \
--key "$CLOUDFORMATION_TEMPLATE_KEY" \
>/dev/null
curl -fsSL \
"https://$CLOUDFORMATION_TEMPLATE_BUCKET.s3.$AWS_REGION.amazonaws.com/$CLOUDFORMATION_TEMPLATE_KEY" \
>/dev/null