Codepet push front and call deploy #47
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: Codepet push front and call deploy | |
on: | |
push: | |
branches: | |
- 'develop' | |
- 'QA' | |
workflow_dispatch: | |
jobs: | |
build_and_push_to_docker_hub_frontend: | |
name: Push Docker image to DockerHub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Extract branch name | |
id: extract_branch | |
run: | | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
BRANCH_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]') | |
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
- name: Push to DockerHub | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}_frontend_${{ steps.extract_branch.outputs.branch_name }}:latest | |
build-args: | | |
NEXT_PUBLIC_CAPTCHA_SITE_KEY=${{ secrets.NEXT_PUBLIC_CAPTCHA_SITE_KEY }} | |
NEXT_PUBLIC_BASE_DEV_URL=${{ secrets.NEXT_PUBLIC_BASE_DEV_URL }} | |
NEXT_PUBLIC_BASE_TEST_URL=${{ secrets.NEXT_PUBLIC_BASE_TEST_URL }} | |
NEXT_PUBLIC_BASE_URL=${{ secrets[format('DOMAIN_{0}', github.ref_name)] }} | |
deploy_uses_other_file_from_develop: | |
if: github.ref == 'refs/heads/develop' | |
uses: Pet-projects-CodePET/Backend/.github/workflows/deploy.yml@develop | |
needs: | |
- build_and_push_to_docker_hub_frontend | |
with: | |
environment: dev | |
secrets: inherit | |
deploy_uses_other_file_from_QA: | |
if: github.ref == 'refs/heads/QA' | |
uses: Pet-projects-CodePET/Backend/.github/workflows/deploy.yml@develop | |
needs: | |
- build_and_push_to_docker_hub_frontend | |
with: | |
environment: prod | |
secrets: inherit |