feat(build-workflow): update branch #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: Build & Push Docker Image | |
on: | |
push: | |
branches: | |
- master | |
release: | |
types: [published] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract version from release tag | |
if: github.event_name == 'release' | |
id: version | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: | | |
docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:main . | |
docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:main . | |
docker push itzcrazykns1337/perplexica-backend:main | |
docker push itzcrazykns1337/perplexica-frontend:main | |
- name: Build and push release Docker image | |
if: github.event_name == 'release' | |
run: | | |
docker build -f backend.dockerfile -t itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} . | |
docker build -f app.dockerfile -t itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} . | |
docker push itzcrazykns1337/perplexica-backend:${{ env.RELEASE_VERSION }} | |
docker push itzcrazykns1337/perplexica-frontend:${{ env.RELEASE_VERSION }} |