Merge pull request #1278 from mild-blue/abragtim/update-rel-dna-ser-d… #69
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Staging Deployment | |
env: | |
AWS_ECR_REPOSITORY: common-txmatching-euw1-be | |
DEPLOYMENT_SERVICE: be | |
SERVER_USERNAME: ubuntu | |
SERVER_URL: txmatching.stg.mild.blue | |
on: | |
# manual dispatch | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
build_server: | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v2 | |
# set release version to the latest commit | |
- name: Set Release Version | |
run: echo "RELEASE_VERSION=${GITHUB_SHA}" >> $GITHUB_ENV | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
# extract metadata for labels https://github.com/crazy-max/ghaction-docker-meta | |
- name: Docker meta | |
id: docker_meta | |
uses: crazy-max/ghaction-docker-meta@v1 | |
with: | |
images: ${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_REPOSITORY }} | |
# setup docker actions https://github.com/docker/build-push-action | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Build and Push Docker Image | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_REPOSITORY }}:stg-latest | |
labels: ${{ steps.docker_meta.outputs.labels }} | |
push: true | |
build-args: | | |
release_version=${{ env.RELEASE_VERSION }} | |
- name: Install SSH key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.STAGING_SSH_KEY }} | |
known_hosts: ${{ secrets.STAGING_SSH_KNOWN_HOST }} | |
- name: Redeploy application | |
run: | | |
ssh "${SERVER_USERNAME}@${SERVER_URL}" "cd /srv/service/txmatching && ./redeploy.sh ${DEPLOYMENT_SERVICE}" |