Skip to content

Fixed build step

Fixed build step #31

name: Publish Docker image
on:
push:
tags:
- '*'
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
publish-docker-images:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Checkout and pull branch
run: |
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $LATEST_TAG
- name: Setup buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERNAME }}
password: ${{ secrets.DOCKERTOKEN }}
- name: Docker meta for core
id: meta_core
uses: docker/metadata-action@v3
with:
images: codelit/medialit
- name: Build and push API
id: docker_build_api
uses: docker/build-push-action@v2
with:
context: .
file: ./apps/api/Dockerfile
push: true
tags: ${{ steps.meta_core.outputs.tags }}
- name: Image digest
run: echo ${{ steps.docker_build_api.outputs.digest }}
- name: Setup AWS ECR Details
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ECR_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_ECR_ACCESS_SECRET }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push docker images to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ secrets.AWS_ECR_REPO }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f apps/web/Dockerfile -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG