Update Dockerfiles to use postgresql16-client and enhance job status … #3
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 Docker Images | |
on: | |
push: | |
branches: [ main, develop ] | |
tags: [ 'v*' ] | |
pull_request: | |
branches: [ main ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
include: | |
- component: api | |
dockerfile: Dockerfile.api | |
context: . | |
- component: worker | |
dockerfile: Dockerfile.worker | |
context: . | |
- component: frontend | |
dockerfile: frontend/Dockerfile | |
context: frontend | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.component }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=raw,value=latest,enable={{is_default_branch}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ${{ matrix.context }} | |
file: ${{ matrix.dockerfile }} | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Job para criar release notes se for tag | |
release: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
body: | | |
## 🚀 PostgreSQL Backup Service ${{ github.ref_name }} | |
### 📦 Docker Images Published: | |
- `ghcr.io/${{ github.repository }}-api:${{ github.ref_name }}` | |
- `ghcr.io/${{ github.repository }}-worker:${{ github.ref_name }}` | |
- `ghcr.io/${{ github.repository }}-frontend:${{ github.ref_name }}` | |
### 🏗️ Architectures: | |
- linux/amd64 | |
- linux/arm64 | |
### 📋 Usage: | |
```bash | |
# Pull images | |
docker pull ghcr.io/${{ github.repository }}-api:${{ github.ref_name }} | |
docker pull ghcr.io/${{ github.repository }}-worker:${{ github.ref_name }} | |
docker pull ghcr.io/${{ github.repository }}-frontend:${{ github.ref_name }} | |
# Or use docker-compose with registry images | |
``` | |
draft: false | |
prerelease: false |