Change in docker context in github actions #10
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: Build and Push | |
on: | |
push: | |
tags: [ 'v*' ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
Dockerfile_Backend: Dockerfile | |
Dockerfile_Web: web/Dockerfile | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Build Web image | |
# if: github.event_name == 'pull_request' | |
run: | | |
env && cat ~/.aws/credentials | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Setup AWS Creds | |
uses: aws-actions/[email protected] | |
with: | |
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: login ECR | |
if: github.event_name != 'pull_request' | |
id: ecr-login | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build Backend and and push | |
if: github.event_name != 'pull_request' | |
env: | |
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets.BACKEND_ECR_REPOSITORY }} | |
run: | | |
VERSION_TAG=$(echo "${{ github.ref }}" | cut -d'/' -f 3) | |
TAG=$ECR_REGISTRY/$ECR_REPOSITORY:${VERSION_TAG} | |
docker build --platform linux/amd64 --push -t ${TAG} -f ${{ env.Dockerfile_Backend }} . | |
- name: Build Backend image | |
if: github.event_name == 'pull_request' | |
run: | | |
docker build --platform linux/amd64 -f ${{ env.Dockerfile_Backend }} . | |
- name: Build Web and and push | |
if: github.event_name != 'pull_request' | |
env: | |
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }} | |
ECR_REPOSITORY: ${{ secrets.WEB_ECR_REPOSITORY }} | |
run: | | |
VERSION_TAG=$(echo "${{ github.ref }}" | cut -d'/' -f 3) | |
TAG=$ECR_REGISTRY/$ECR_REPOSITORY:${VERSION_TAG} | |
docker build --platform linux/amd64 --push -t ${TAG} -f ${{ env.Dockerfile_Web }} web/ | |
- name: Build Web image | |
if: github.event_name == 'pull_request' | |
run: | | |
docker build --platform linux/amd64 -f ${{ env.Dockerfile_Web }} web/ | |