Automatic docker build #1
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: Docker Build (Dev) | ||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
branches: | ||
- dev | ||
jobs: | ||
build: | ||
Check failure on line 11 in .github/workflows/docker-build-dev.yml
|
||
if: github.event.pull_request.merged == true # Only run if the PR was merged | ||
runs-on: ubuntu-latest | ||
needs: lint # Reference the lint job from eslint.yml | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- 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: ${{ vars.AWS_REGION }} | ||
- name: Log in to AWS ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
- name: Extract repository name and short commit ID | ||
id: extract_repo | ||
run: | | ||
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}' | tr '[:upper:]' '[:lower:]') | ||
SHORT_COMMIT_ID=$(echo "${{ github.sha }}" | cut -c1-7) | ||
echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT | ||
echo "short_commit_id=${SHORT_COMMIT_ID}" >> $GITHUB_OUTPUT | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ steps.login-ecr.outputs.registry }}/${{ steps.extract_repo.outputs.repo_name }}:dev-${{ steps.extract_repo.outputs.short_commit_id }} | ||
${{ steps.login-ecr.outputs.registry }}/${{ steps.extract_repo.outputs.repo_name }}:dev-latest |