Skip to content

Commit

Permalink
feat(pipelines): ecr integration (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-lx authored Nov 29, 2021
1 parent c3826b0 commit e22a626
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/merge-master.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: Merge master



on:
push:
branches:
- master



jobs:
prepare:
name: Calculate Version and Build Number
Expand Down
45 changes: 28 additions & 17 deletions .github/workflows/prereleased.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
name: Prereleased



on:
release:
types:
- prereleased



env:
COMPONENT: authentication-service
COMPONENT_PATH: apps/authentication-service
COMPONENT_PATH: contrib

PRIVATE_ECR_ACCESSKEYID: ${{ secrets.AWS_ECR_ACCESSKEYID }}
PRIVATE_ECR_SECRETACCESSKEY: ${{ secrets.AWS_ECR_SECRETACCESSKEY }}
PRIVATE_ECR_REGION: ${{ secrets.AWS_ECR_REGION }}

CONTAINER: authentication-service-container-image
DOCKER_REPOSITORY: authentication-service

CONTAINER: container_image
DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/authentication-service


jobs:
Expand Down Expand Up @@ -53,22 +61,25 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: docker/login-action@v1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
registry: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}
aws-access-key-id: ${{ env.PRIVATE_ECR_ACCESSKEYID }}
aws-secret-access-key: ${{ env.PRIVATE_ECR_SECRETACCESSKEY }}
aws-region: ${{ env.PRIVATE_ECR_REGION }}

- uses: docker/setup-buildx-action@v1
- name: Login to Amazon ECR
id: ecr_password
uses: aws-actions/amazon-ecr-login@v1

- uses: docker/build-push-action@v2
id: docker_build
- name: Build and push
uses: docker/build-push-action@v2
env:
DOCKER_IMAGE_TAG: ${{ steps.ecr_password.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}
with:
file: Dockerfile
context: .
push: true
tags: ${{ env.DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GHCR_TOKEN }}
tags: ${{ env.DOCKER_IMAGE_TAG }}


update-manifests:
Expand All @@ -94,14 +105,14 @@ jobs:
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
cd ${COMPONENT_PATH}
kustomize edit set image ${CONTAINER}=${DOCKER_IMAGE_URL}:${VERSION}
cd ${COMPONENT_PATH}/
kustomize edit set image ${CONTAINER}=${DOCKER_REPOSITORY}:${VERSION}
- name: Commit and push image update into manifests repo
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
git config user.email "[email protected]"
git config user.name "Azory YData Bot"
git commit -a -m "chore(bump): [CI] [DEV] bump ${COMPONENT} to $VERSION"
git commit -a -m "chore(bump): [CI] [DEV] bump ${{ env.COMPONENT }} to $VERSION"
git push origin master
4 changes: 4 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Pull request



on:
pull_request:
branches:
- master



jobs:
build:
name: Build
Expand Down
53 changes: 40 additions & 13 deletions .github/workflows/released.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
name: Released



on:
release:
types:
- released



env:
COMPONENT: authentication-service
COMPONENT_PATH: apps/authentication-service
COMPONENT_PATH: contrib

PRIVATE_ECR_ACCESSKEYID: ${{ secrets.AWS_ECR_ACCESSKEYID }}
PRIVATE_ECR_SECRETACCESSKEY: ${{ secrets.AWS_ECR_SECRETACCESSKEY }}
PRIVATE_ECR_REGION: ${{ secrets.AWS_ECR_REGION }}

CONTAINER: authentication-service-container-image
DOCKER_REPOSITORY: authentication-service

CONTAINER: container_image
DOCKER_IMAGE_URL: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}/${{ github.repository_owner }}/authentication-service


jobs:
cancel_previous:
name: 'Cancel Previous Runs'
runs-on: ubuntu-20.04
timeout-minutes: 3

steps:
- uses: ydataai/[email protected]
with:
ignore_sha: true
access_token: ${{ secrets.ACCESS_TOKEN }}


prepare:
name: Extract Version and Build number
name: Prepare
runs-on: ubuntu-20.04

needs:
- cancel_previous

outputs:
build_number: ${{ steps.short_sha.outputs.value }}
version: ${{ steps.version.outputs.value }}
Expand All @@ -43,17 +66,21 @@ jobs:
- prepare

steps:
- name: Login to GitHub docker
uses: docker/login-action@v1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
registry: ${{ secrets.PRIVATE_CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
aws-access-key-id: ${{ env.PRIVATE_ECR_ACCESSKEYID }}
aws-secret-access-key: ${{ env.PRIVATE_ECR_SECRETACCESSKEY }}
aws-region: ${{ env.PRIVATE_ECR_REGION }}

- name: Login to Amazon ECR
id: ecr_password
uses: aws-actions/amazon-ecr-login@v1

- name: Docker tag and push
env:
SOURCE: ${{ env.DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
DESTINATION: ${{ env.DOCKER_IMAGE_URL }}:${{ needs.prepare.outputs.version }}
SOURCE: ${{ steps.ecr_password.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.build_number }}
DESTINATION: ${{ steps.ecr_password.outputs.registry }}/${{ env.DOCKER_REPOSITORY }}:${{ needs.prepare.outputs.version }}
run: |
docker pull $SOURCE
docker tag $SOURCE $DESTINATION
Expand Down Expand Up @@ -83,8 +110,8 @@ jobs:
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
cd ${COMPONENT_PATH}
kustomize edit set image ${CONTAINER}=${DOCKER_IMAGE_URL}:${VERSION}
cd ${COMPONENT_PATH}/
kustomize edit set image ${CONTAINER}=${DOCKER_REPOSITORY}:${VERSION}
- name: Commit and push image update into manifests repo
env:
Expand Down

0 comments on commit e22a626

Please sign in to comment.