Skip to content

Add files via upload #12

Add files via upload

Add files via upload #12

name: Publish Docker image
on:
push:
branches:
- main
workflow_dispatch:
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
attestations: write
id-token: write
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up the date and revision tag
id: vars
run: |
DATE_TAG=$(date +'%Y%m%d')
REVISION_TAG=$(cat REVISION_TAG || echo "0")
REVISION_TAG=$((REVISION_TAG + 1))
echo "${REVISION_TAG}" > REVISION_TAG
echo "TAG=${DATE_TAG}.${REVISION_TAG}" >> $GITHUB_ENV
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: |
${{ secrets.DOCKER_USERNAME }}/fiap-8soat-tc:backend-${{ env.TAG }}
${{ secrets.DOCKER_USERNAME }}/fiap-8soat-tc:latest
platforms: linux/amd64
- name: Push Docker image (amd64)
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/fiap-8soat-tc:backend-${{ env.TAG }}
docker push ${{ secrets.DOCKER_USERNAME }}/fiap-8soat-tc:latest
- name: Commit revision tag
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git tag release-${{ env.TAG }}
git push origin release-${{ env.TAG }}