Merge pull request #512 from DrDroidLab/fix/migrate-dockerhub #66
Workflow file for this run
This file contains hidden or 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: warp-ubuntu-latest-x64-16x-spot | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3.0.0 | |
| - name: Login to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_TEAM_NAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build Backend and push | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| VERSION_TAG=$(echo "${{ github.ref }}" | cut -d'/' -f 3) | |
| REPO_NAME=${{ secrets.DOCKERHUB_TEAM_NAME }}/${{ secrets.BACKEND_REPOSITORY }} | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --tag ${REPO_NAME}:${VERSION_TAG} \ | |
| --tag ${REPO_NAME}:latest \ | |
| --push \ | |
| --file ${{ env.Dockerfile_Backend }} \ | |
| . | |
| - name: Build Backend image | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --file ${{ env.Dockerfile_Backend }} \ | |
| . | |
| - name: Build Web and push | |
| if: github.event_name != 'pull_request' | |
| run: | | |
| VERSION_TAG=$(echo "${{ github.ref }}" | cut -d'/' -f 3) | |
| REPO_NAME=${{ secrets.DOCKERHUB_TEAM_NAME }}/${{ secrets.WEB_REPOSITORY }} | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --tag ${REPO_NAME}:${VERSION_TAG} \ | |
| --tag ${REPO_NAME}:latest \ | |
| --push \ | |
| --file ${{ env.Dockerfile_Web }} \ | |
| web/ | |
| - name: Build Web image | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64 \ | |
| --file ${{ env.Dockerfile_Web }} \ | |
| web/ | |