forked from ministryofjustice/fb-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub action for docker image building
As per subject, added the steps to build docker images on every push This can be refined at a later date, for now I'm more concerned that the built images can be pushed to the ECR without an issue
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Build and upload docker images | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
permissions: | ||
id-token: write # for JWT request | ||
contents: read # for actions/checkout | ||
|
||
jobs: | ||
docker-image-build: | ||
name: docker-image-build | ||
runs-on: ubuntu-latest | ||
environment: preprod | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/[email protected] | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/[email protected] | ||
with: | ||
role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }} | ||
aws-region: eu-west-2 | ||
role-session-name: github-aws-access | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/[email protected] | ||
- name: Build fb-runner, tag, and push docker image to Amazon ECR | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
REPOSITORY: "fb-runner" | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -t ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} . | ||
docker tag ${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} | ||
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }} |