dit and ditt #24
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: Publish Docker image | |
on: | |
push: | |
branches: | |
jobs: | |
buid_and_publush_dockergiot : | |
name: Push Docker image to ECR | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Build docker image | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 244530008913.dkr.ecr.eu-west-1.amazonaws.com | |
rev=$(git rev-parse --short HEAD) | |
docker build . -t hello | |
- name: Push docker image on main branch push | |
if: github.ref == 'refs/heads/main' | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
docker tag hello 244530008913.dkr.ecr.eu-west-1.amazonaws.com/vincent-ppe:$rev | |
docker tag hello 244530008913.dkr.ecr.eu-west-1.amazonaws.com/vincent-ppe:latest | |
docker push 244530008913.dkr.ecr.eu-west-1.amazonaws.com/vincent-ppe:$rev | |
docker push 244530008913.dkr.ecr.eu-west-1.amazonaws.com/vincent-ppe:latest | |