-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (108 loc) · 3.8 KB
/
full-deployment.yaml
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
name: Deploy a full deployment package/version to AWS/GCP
on:
workflow_call:
inputs:
tag:
required: true
type: string
env:
MIX_ENV: prod
jobs:
build:
name: Building a release and version file
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict
- name: Update project mix version
run: |
sed -i "s/.*version:.*/ version: \"${{ inputs.tag }}\",/" mix.exs
- name: Create Release file version
run: |
echo "{\"version\":\"${{ inputs.tag }}\",\"hash\":\"${GITHUB_SHA}\"}" | jq > current.json
- name: Install Elixir dependencies
run: mix do deps.get, compile
- name: Assets Deploy
run: mix assets.deploy
- name: Generate a Release
run: mix release
- name: 'Upload release file artifact'
uses: actions/upload-artifact@v4
with:
name: release-file
path: _build/prod/calori-${{ inputs.tag }}.tar.gz
retention-days: 5
- name: 'Upload version file artifact'
uses: actions/upload-artifact@v4
with:
name: version-file
path: current.json
retention-days: 5
upload_aws:
name: Upload files to AWS environment
needs: build
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: Download version file artefact
uses: actions/download-artifact@v4
with:
name: version-file
- name: Download release file artefact
uses: actions/download-artifact@v4
with:
name: release-file
- name: Copy a release file to the s3 distribution folder
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: "sa-east-1"
source: "calori-${{ inputs.tag }}.tar.gz"
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/dist/calori/calori-${{ inputs.tag }}.tar.gz"
- name: Copy a version file to the s3 version folder
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: "sa-east-1"
source: "current.json"
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}/current.json"
upload_gcp:
name: Upload files to GCP environment
needs: build
runs-on: ubuntu-20.04
permissions:
contents: write
id-token: write
steps:
- name: Download version file artefact
uses: actions/download-artifact@v4
with:
name: version-file
- name: Download release file artefact
uses: actions/download-artifact@v4
with:
name: release-file
- id: 'auth'
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}
- id: 'upload-release-file'
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: 'calori-${{ inputs.tag }}.tar.gz'
destination: "calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/dist/calori"
process_gcloudignore: false
- id: 'upload-version-file'
uses: 'google-github-actions/upload-cloud-storage@v2'
with:
path: 'current.json'
destination: "calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}"
process_gcloudignore: false