Skip to content

Commit

Permalink
adds ECR image push
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoFerraz committed Mar 2, 2024
1 parent 21c562b commit b199a98
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ecr-build-and-push-images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Documentation: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: Build and push service image

on:
push:
branches:
- release

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
set_environment:
runs-on: ubuntu-latest # included software: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
outputs:
short_sha: ${{ steps.git.outputs.short_sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Short SHA
id: git
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"

build:
needs: set_environment
runs-on: ubuntu-latest # included software: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1.0.2 # https://github.com/marketplace/actions/docker-setup-buildx
with:
driver-opts: image=moby/buildkit:buildx-stable-1

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2 # https://github.com/marketplace/actions/amazon-ecr-login-action-for-github-actions

- name: Build and export
id: docker-build
uses: docker/build-push-action@v2 # https://github.com/marketplace/actions/build-and-push-docker-images
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/armitage:${{ github.run_number }}-${{ needs.set_environment.outputs.short_sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit b199a98

Please sign in to comment.