Merge pull request #8 from SkywardAI/fix/ci #13
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: 'Backend CI/CD 🚀' | |
on: | |
push: | |
branches: | |
- 'main' | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- 'main' | |
jobs: | |
docker_operations: | |
name: 'Docker Build and Push🐳' | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Check repository | |
uses: actions/checkout@v4 | |
- name: Login to Container Registry | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success() | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build Docker image | |
if: startsWith(github.ref, 'refs/tags/') != true && success() | |
run: | | |
docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_SHA::7} . | |
- name: Push Docker image | |
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/') && success() | |
run: | | |
docker build -t ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//} . | |
docker push ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.IMAGE_NAME }}:${GITHUB_REF/refs\/tags\//} |