Skip to content

Publish

Publish #55

Workflow file for this run

name: Publish
on:
workflow_dispatch:
push:
tags:
- "v*"
branches:
- master
env:
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_READ_WRITE_USERNAME }}
password: ${{ secrets.GHCR_READ_WRITE_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ env.IMAGE_NAME }}
flavor: |
latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Build Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
depoly-gz:
runs-on: ubuntu-latest
environment: gz
needs: build-and-push-image
if: ${{ needs.build-and-push-image.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: ./.github/actions/deploy/
with:
version: ${{ needs.build-and-push-image.outputs.version }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-port: ${{ secrets.SSH_PORT }}
ssh-username: ${{ secrets.SSH_USERNAME }}
ssh-key: ${{ secrets.SSH_KEY }}
dyups-token: ${{ secrets.DYUPS_TOKEN }}
dyups-db-host: ${{ secrets.DYUPS_DB_HOST }}
dyups-db-port: ${{ secrets.DYUPS_DB_PORT }}
dyups-db-database: ${{ secrets.DYUPS_DB_DATABASE }}
dyups-db-user: ${{ secrets.DYUPS_DB_USER }}
dyups-db-password: ${{ secrets.DYUPS_DB_PASSWORD }}
dyups-db-charset: ${{ secrets.DYUPS_DB_CHARSET }}
depoly-sg:
runs-on: ubuntu-latest
environment: sg
needs: [depoly-gz, build-and-push-image]
if: ${{ needs.depoly-gz.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: ./.github/actions/deploy/
with:
version: ${{ needs.build-and-push-image.outputs.version }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-port: ${{ secrets.SSH_PORT }}
ssh-username: ${{ secrets.SSH_USERNAME }}
ssh-key: ${{ secrets.SSH_KEY }}
dyups-token: ${{ secrets.DYUPS_TOKEN }}
dyups-db-host: ${{ secrets.DYUPS_DB_HOST }}
dyups-db-port: ${{ secrets.DYUPS_DB_PORT }}
dyups-db-database: ${{ secrets.DYUPS_DB_DATABASE }}
dyups-db-user: ${{ secrets.DYUPS_DB_USER }}
dyups-db-password: ${{ secrets.DYUPS_DB_PASSWORD }}
dyups-db-charset: ${{ secrets.DYUPS_DB_CHARSET }}
depoly-bj:
runs-on: ubuntu-latest
environment: bj
needs: [depoly-sg, build-and-push-image]
if: ${{ needs.depoly-sg.result == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: ./.github/actions/deploy/
with:
version: ${{ needs.build-and-push-image.outputs.version }}
ssh-host: ${{ secrets.SSH_HOST }}
ssh-port: ${{ secrets.SSH_PORT }}
ssh-username: ${{ secrets.SSH_USERNAME }}
ssh-key: ${{ secrets.SSH_KEY }}
dyups-token: ${{ secrets.DYUPS_TOKEN }}
dyups-db-host: ${{ secrets.DYUPS_DB_HOST }}
dyups-db-port: ${{ secrets.DYUPS_DB_PORT }}
dyups-db-database: ${{ secrets.DYUPS_DB_DATABASE }}
dyups-db-user: ${{ secrets.DYUPS_DB_USER }}
dyups-db-password: ${{ secrets.DYUPS_DB_PASSWORD }}
dyups-db-charset: ${{ secrets.DYUPS_DB_CHARSET }}