-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (98 loc) · 3.32 KB
/
deploy.yml
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
name: Deploy
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag to deploy'
required: false
default: ''
workflow_run:
workflows: [Build]
types:
- completed
concurrency:
group: ${{ github.workflow }}
jobs:
Deploy:
runs-on: ubuntu-latest
steps:
- name: Get latest version
if: ${{ ! contains(inputs.version, '.') }}
id: latest
uses: gregziegan/[email protected]
- name: Resolve version
id: version
uses: haya14busa/action-cond@v1
with:
cond: ${{ ! contains(inputs.version, '.') }}
if_true: ${{ steps.latest.outputs.name }}
if_false: ${{ inputs.version }}
- uses: robinraju/[email protected]
with:
tag: ${{ steps.version.outputs.value }}
fileName: "blog-*.zip"
tarBall: false
zipBall: false
extract: true
- uses: chrnorm/deployment-action@releases/v1
name: Create deployment for ${{ steps.version.outputs.value }}
id: deployment
with:
token: ${{ secrets.PAT }}
description: ${{ steps.version.outputs.value }}
environment: production
- name: Setup AWS CLI
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-session-token: ""
aws-region: eu-west-1
unset-current-credentials: true
- name: Upload static assets
run: |
cd static
aws s3 sync . s3://jamiehurst-blog-static/
- name: Get current live colour
id: live_colour
run: |
aws --region us-east-1 ssm get-parameter \
--name blog-blue-green \
--with-decryption \
--query 'Parameter.Value' \
--output text
- name: Get opposite colour for release
id: release_colour
uses: haya14busa/action-cond@v1
with:
cond: ${{ ! contains(steps.live_colour.outputs.value, 'blue') }}
if_true: green
if_false: blue
- name: Upload ${{ steps.version.outputs.value }} to ${{ steps.release_colour.outputs.value }}
run: |
rm *.zip
rm -Rf static
aws s3 sync . s3://jamiehurst-blog-${{ steps.release_colour.outputs.value }}/ --delete
- name: Switch colour to ${{ steps.release_colour.outputs.value }}
run: |
aws --region us-east-1 ssm put-parameter \
--name blog-blue-green \
--type String \
--overwrite \
--value "${{ steps.release_colour.outputs.value }}"
- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@v2
with:
token: ${{ secrets.PAT }}
environment-url: https://jamiehurst.co.uk
state: success
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@v2
with:
token: ${{ secrets.PAT }}
environment-url: https://jamiehurst.co.uk
state: failure
deployment-id: ${{ steps.deployment.outputs.deployment_id }}