1 Commits

Author SHA1 Message Date
fc19676a8d Preparando release
Some checks failed
Creates a docker image for production / Build the docker image (push) Failing after 12s
Build / Code quality (push) Has been cancelled
2025-02-05 10:06:48 -03:00

View File

@@ -3,71 +3,63 @@ name: Creates a docker image for production
on:
push:
tags:
- 'v*'
- "v*"
jobs:
build:
build_docker:
name: Build the docker image
runs-on: ubuntu-latest
steps:
- name: Build started
uses: voxmedia/github-action-slack-notify-build@v1
if: success()
with:
channel: ci-notifications
status: STARTED
color: good
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
- name: Log in to Nexus Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
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@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v5
with:
images: redbeard/mines-backend
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
env:
SCOPE: production
images: docker.nexus.makecodes.dev/mines/backend
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build finished
if: success()
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel: ci-notifications
status: SUCCESS
color: good
- 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/makecodes/nfe-vision",
# "service": "nfe-vision_app",
# "version": "${{ github.ref_name }}",
# "pipeline": "${{ github.run_number }}",
# "repository": "makecodes/nfe-vision"
# }'
# 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:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
deploy:
name: Deploy
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.SSH_PORT }}
script: |
cd /media/data/apps/mines-backend
docker pull redbeard/mines-backend:latest
docker-compose up -d app0
docker-compose up -d app1
docker exec -t mines-be0 python manage.py migrate
docker image prune -f
USERNAME: ${{ secrets.SERVER_AUTH_USERNAME }}
PASSWORD: ${{ secrets.SERVER_AUTH_PASSWORD }}