Files
frontend/.gitea/workflows/on_release.yml

56 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/frontend
- 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/frontend",
# "service": "mines_frontend",
# "version": "${{ github.ref_name }}",
# "pipeline": "${{ github.run_number }}",
# "repository": "mines/frontend"
# }'
env:
USERNAME: ${{ secrets.SERVER_AUTH_USERNAME }}
PASSWORD: ${{ secrets.SERVER_AUTH_PASSWORD }}