Skip to content

full-deploy

full-deploy #114

Workflow file for this run

name: full-deploy
on:
workflow_dispatch:
inputs:
semver-type:
type: choice
description: The semver type
default: minor
options:
- major
- minor
- patch
jobs:
snap:
runs-on: self-hosted
timeout-minutes: 10
steps:
- name: Checkout KMQ_Discord
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18
- name: Snap prod branch
run: |
git config --global user.name 'KMQ GH Action Committer'
git config --global user.email '<>'
git checkout master
echo $PATH
npm version ${{ github.event.inputs.semver-type }}
git push --follow-tags
git checkout prod
echo "Checking out 'prod', latest commit:"
git log -n 1 --pretty
git pull --rebase origin master
echo "Rebasing off 'master', latest commit:"
git log -n 1 --pretty
git push
echo "Pushing new prod branch"
build-and-push-image:
needs: snap
runs-on: self-hosted
outputs:
image-name: ${{ steps.app-version-parser.outputs.IMAGE_NAME }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: prod
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get application version
id: app-version-parser
run: |
APP_VERSION=$(npm pkg get version | sed 's/"//g')
echo IMAGE_NAME=ghcr.io/brainicism/kmq_discord:$APP_VERSION > $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/kmq/Dockerfile
push: true
platforms: linux/arm64
tags: ${{ steps.app-version-parser.outputs.IMAGE_NAME }},ghcr.io/brainicism/kmq_discord:latest
upgrade:
uses: Brainicism/KMQ_Discord/.github/workflows/upgrade-prod.yml@master
needs: build-and-push-image
secrets:
SSH_DEPLOY_PRIVATE_KEY: ${{ secrets.SSH_DEPLOY_PRIVATE_KEY }}
PROD_SSH_ADDRESS: ${{ secrets.PROD_SSH_ADDRESS }}
PROD_SSH_USER: ${{ secrets.PROD_SSH_USER }}
with:
image-name: ${{ needs.build-and-push-image.outputs.image-name }}