Skip to content

Merge pull request #389 from Pet-projects-CodePET/refactor/requests_a… #139

Merge pull request #389 from Pet-projects-CodePET/refactor/requests_a…

Merge pull request #389 from Pet-projects-CodePET/refactor/requests_a… #139

name: Codepet build nginx and backend from Develop
on:
push:
branches:
- 'develop'
- 'QA'
workflow_dispatch:
jobs:
build_and_push_to_docker_hub_backend:
name: Push backend 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 }}_backend_${{ steps.extract_branch.outputs.branch_name }}:latest
build_and_push_to_docker_hub_nginx:
name: Push nginx 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: ./infra/nginx/
push: true
build-args: |
NGINX_NAME=${{ secrets.NGINX_NAME }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}_nginx_${{ steps.extract_branch.outputs.branch_name }}:latest
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_backend
- build_and_push_to_docker_hub_nginx
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_backend
- build_and_push_to_docker_hub_nginx
with:
environment: prod
secrets: inherit