Files
backend/.gitea/workflows/on_release.yml
Michel Wilhelm 96afac4789
Some checks failed
Creates a docker image for production / Build the docker image (push) Successful in 1m7s
Build / Code quality (push) Has been cancelled
Habilitando deploy automático
2025-02-05 10:34:00 -03:00

66 lines
2.4 KiB
YAML

name: Creates a docker image for production
on:
push:
tags:
- "v*"
jobs:
build_docker:
name: Build the docker image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Log in to Nexus Docker Hub
uses: docker/login-action@v3
with:
registry: docker.nexus.makecodes.dev
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: docker.nexus.makecodes.dev/mines/backend
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Deploy to production server
run: |
TOKEN=$(curl --silent --location 'https://auth.makecodes.dev/auth' \
--header 'Content-Type: application/json' \
--data '{
"email": "'$USERNAME'",
"password": "'$PASSWORD'"
}' | jq -r '.token')
curl --location --silent 'https://deployer.makecodes.dev/deploy' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TOKEN" \
--data '{
"image": "docker.nexus.makecodes.dev/mines/backend",
"service": "nfe-vision_app",
"version": "${{ github.ref_name }}",
"pipeline": "${{ github.run_number }}",
"repository": "mines/backend"
}'
# curl --location --silent 'https://deployer.makecodes.dev/deploy' \
# --header 'Content-Type: application/json' \
# --header "Authorization: Bearer $TOKEN" \
# --data '{
# "image": "docker.nexus.makecodes.dev/makecodes/nfe-vision",
# "service": "nfe-vision_worker",
# "version": "${{ github.ref_name }}",
# "pipeline": "${{ github.run_number }}",
# "repository": "makecodes/nfe-vision"
# }'
env:
USERNAME: ${{ secrets.SERVER_AUTH_USERNAME }}
PASSWORD: ${{ secrets.SERVER_AUTH_PASSWORD }}