Skip to content

Deploy

Deploy #15

Workflow file for this run

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 }}