ClemBot.Api-deployment #74
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ClemBot.Api-deployment | |
on: | |
push: | |
branches: [ master ] | |
paths: | |
- "ClemBot.Api/**" | |
workflow_dispatch: | |
inputs: | |
name: | |
description: 'Manual ClemBot.Api workflow trigger' | |
required: true | |
default: 'Manual Deployment' | |
permissions: | |
packages: write | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-push-clembot-api: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/#-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1.5.1 | |
with: | |
version: latest | |
install: true | |
- name: Extract Docker metadata for main build | |
id: meta | |
uses: docker/metadata-action@v3.4.1 | |
with: | |
images: ${{ env.REGISTRY }}/ClemBotProject/ClemBot.Api | |
flavor: | | |
latest=${{ github.event_name == 'push' }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v2.6.1 | |
with: | |
context: ./ClemBot.Api | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-to: type=gha, scope=${{github.repository}} | |
cache-from: type=gha, scope=${{github.repository}} | |
deploy-clembot-api: | |
runs-on: [self-hosted] | |
needs: ['build-push-clembot-api'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Copy Secrets | |
run: | | |
cp ~/ClemBot.Api_env.env ./ClemBot.Api/ClemBot.Api_env.env | |
cp ~/ClemBot.Bot_env.env ./ClemBot.Bot/ClemBot.Bot_env.env | |
cp ~/ClemBot.Site_env.env ./ClemBot.Site/ClemBot.Site_env.env | |
- name: Login to GitHub Container Registry | |
uses: docker/#-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy updated images | |
run: | | |
docker-compose pull clembot.api | |
docker-compose up -d clembot.api | |
- name: Discord notification | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.WEBHOOK_URL }} | |
uses: "Ilshidur/action-discord@0.3.0" | |
with: | |
args: 'The project {{ EVENT_PAYLOAD.repository.full_name }}/ClemBot.Api has been deployed.' |