Manual build #29
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: Manual build | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
services: | |
description: 'List of services to rebuild' | |
required: true | |
extraparameters: | |
description: 'Extra parameters for docker-compose up -d' | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build: | |
runs-on: self-hosted | |
permissions: | |
id-token: write | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
name: Checkout repo | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --remote | |
- name: Create env file | |
run: | | |
touch .env | |
# Front version | |
export PUBLIC_VERSION=$(jq -r .version utile-front/package.json) | |
cat << EOF > .env | |
NOTION_SECRET=${{ secrets.NOTION_SECRET }} | |
NOTION_DATABASE_ID=${{ secrets.NOTION_DATABASE_ID }} | |
TWITTER_POST_URL=${{ secrets.TWITTER_POST_URL }} | |
BOT_TOKEN=${{ secrets.BOT_TOKEN }} | |
# Front env var, note that the prefix VITE_ is required | |
PUBLIC_VERSION=${PUBLIC_VERSION} | |
VITE_API_URL=${{ secrets.API_URL }} | |
EOF | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update the stack on the production server | |
run: docker compose --env-file /etc/environment up --remove-orphans -d ${{ github.event.inputs.extraparameters }} ${{ github.event.inputs.services }} | |
- name: Cleans up useless images | |
run: docker image prune --force |