Build and Deploy #10
Workflow file for this run
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 and Deploy | |
permissions: | |
contents: read | |
packages: write | |
on: | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build: | |
name: Build and Push Docker images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/itsamirhn/bonbast-api:latest | |
ghcr.io/itsamirhn/bonbast-api:${{ github.ref_name }} | |
deploy: | |
name: Deploy API | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Push to dokku | |
uses: dokku/github-action@master | |
with: | |
git_remote_url: 'ssh://dokku@${{ vars.DOKKU_HOST }}:22/${{ vars.DOKKU_APP_NAME }}' | |
ssh_private_key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }} | |
deploy_docker_image: 'ghcr.io/itsamirhn/bonbast-api:${{ github.ref_name }}' |