deploy-front #129
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: API Trigger | |
on: | |
# Allows to receive event through the REST API | |
repository_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build: | |
runs-on: self-hosted | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
name: Checkout repo | |
- name: Checkout submodules | |
run: git submodule update --init --recursive --remote | |
- name: Create env file | |
run: | | |
touch .env | |
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.client_payload.service }} | |
- name: Cleans up useless images | |
run: docker image prune --force |