♻️ (on_release.yml): Remove redundant curl command to clean up the code and improve readability
57 lines
1.9 KiB
YAML
57 lines
1.9 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: |
|
|
echo "${{ github.ref_name }} - ${{ github.run_number }}"
|
|
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": "mines_backend",
|
|
"version": "${{ github.ref_name }}",
|
|
"pipeline": "${{ github.run_number }}",
|
|
"repository": "mines/backend"
|
|
}'
|
|
env:
|
|
USERNAME: ${{ secrets.SERVER_AUTH_USERNAME }}
|
|
PASSWORD: ${{ secrets.SERVER_AUTH_PASSWORD }}
|