This repository was archived by the owner on Mar 29, 2025. It is now read-only.
Updated web
service external port
#21
This file contains hidden or 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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
env: | |
DOMAIN: ${{ vars.DOMAIN }} | |
IMAGE_NAME: ${{ github.repository }} | |
REGISTRY: ghcr.io | |
STACK_NAME: swarmy | |
jobs: | |
publish-images: | |
name: Publish `${{ matrix.name }}` image | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- name: api | |
- name: web | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.name }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
type=sha | |
- name: Build & push image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./services/${{ matrix.name }}/Dockerfile | |
labels: ${{ steps.meta.outputs.labels }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: | |
- publish-images | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure Docker context | |
uses: amirmarmul/docker-context-ssh-action@v1 | |
with: | |
context-name: ${{ env.STACK_NAME }} | |
context-use: true | |
ssh-host: ${{ secrets.SSH_HOSTNAME }} | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
ssh-username: ${{ secrets.SSH_USERNAME }} | |
- name: Deploy stack | |
env: | |
CLOUDFLARE_DNS_API_TOKEN: ${{ secrets.CLOUDFLARE_DNS_API_TOKEN }} | |
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }} | |
DOMAIN: ${{ env.DOMAIN }} | |
run: docker stack deploy -c infra/config/docker-compose.yml ${{ env.STACK_NAME }} --with-registry-auth |