Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure CI/CD pipeline #1285

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 13 additions & 31 deletions .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,25 @@ jobs:
steps:
- uses: actions/checkout@v2

# set release version to the latest commit
- name: Set Release Version
run: echo "RELEASE_VERSION=${GITHUB_SHA}" >> $GITHUB_ENV
run: |
echo "Version: ${GITHUB_REF:10}"

- 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
# this is for in-app version label
echo "APP_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# this is for taging docker image
echo "RELEASE_VERSION=stg-latest" >> $GITHUB_ENV

# 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 }}
- name: Login to Azure
id: login-ecr
run: docker login txmatching.azurecr.io -u ${{ secrets.AZURE_CR_PUSH_USERERNAME }} -p ${{ secrets.AZURE_CR_PUSH_PASSWORD }}

# 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
run: docker compose -f compose-deploy.yml build --build-arg release_version=${{ env.APP_VERSION }}

- 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: Push
run: docker compose -f compose-deploy.yml push

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
Expand Down
49 changes: 11 additions & 38 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,28 @@
name: Release Pipeline

env:
AWS_ECR_REPOSITORY: common-txmatching-euw1-be

on:
workflow_dispatch:
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
- name: Set envs
# use the latest tag as release version
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $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: Set Release Version
run: |
echo "Version: ${GITHUB_REF:10}"
echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV

- name: Login to Amazon ECR
- name: Login to Azure
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 }}
run: docker login txmatching.azurecr.io -u ${{ secrets.AZURE_CR_PUSH_USERERNAME }} -p ${{ secrets.AZURE_CR_PUSH_PASSWORD }}

# 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
run: docker compose -f compose-deploy.yml build --build-arg release_version=${{ env.RELEASE_VERSION }}

- 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 }}:${{ env.RELEASE_VERSION }}
${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_REPOSITORY }}:prd-latest
labels: ${{ steps.docker_meta.outputs.labels }}
push: true
build-args: |
release_version=${{ env.RELEASE_VERSION }}
- name: Push
run: docker compose -f compose-deploy.yml push
7 changes: 7 additions & 0 deletions compose-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:
backend:
image: txmatching.azurecr.io/common-txmatching-euw1-be:${RELEASE_VERSION?}
build:
context: .
dockerfile: Dockerfile

Loading