Skip to content

Nightly

Nightly #11

Workflow file for this run

name: Nightly
on:
push:
paths-ignore:
- "*.md"
- ".github/**"
- "!.github/workflows/docker-nightly.yml"
branches:
- main
workflow_dispatch:
jobs:
determine-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set matrix
id: set-matrix
run: |
APPS=("website" "telegram-game")
CHANGED=()
for app in "${APPS[@]}"; do
folder="apps/${app}"
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "^${folder}/"; then
CHANGED+=("${app}")
fi
done
if [ ${#CHANGED[@]} -gt 0 ]; then
echo "matrix=$(printf '%s\n' "${CHANGED[@]}" | jq -R . | jq -s . | tr -d '[:space:]')" >> $GITHUB_OUTPUT
else
echo "matrix=[]" >> $GITHUB_OUTPUT
fi
- name: Result
run: |
echo "${{ steps.set-matrix.outputs.matrix }}"
build:
needs: determine-changes
if: ${{ needs.determine-changes.outputs.matrix != '[]' }}
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
app: ${{ fromJson(needs.determine-changes.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set APP in env
run: |
echo "APP_NAME=${{ matrix.app }}" >> $GITHUB_ENV
echo "APP_VERSION=nightly" >> $GITHUB_ENV
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.package }}
uses: docker/build-push-action@v6
with:
context: .
file: docker/${{ env.APP_NAME }}/Dockerfile
push: true
tags: ${{ secrets.NAMESPACE }}/${{ env.APP_NAME }}:${{ env.APP_VERSION }}
deploy:
needs: [determine-changes, build]
if: ${{ needs.determine-changes.outputs.matrix != '[]' }}
runs-on: ubuntu-latest
strategy:
matrix:
app: ${{ fromJson(needs.determine-changes.outputs.matrix) }}
permissions:
deployments: write
steps:
- name: Set APP ID in env
id: set-app-id
run: |
app_id=$(echo '${{ secrets.DOKPLOY_STAGE_APPS }}' | jq -r '."${{ matrix.app }}"')
echo "::add-mask::$app_id"
echo "APP_ID=$app_id" >> $GITHUB_OUTPUT
- name: Create GitHub deployment
if: ${{ steps.set-app-id.outputs.APP_ID != '' }}
uses: chrnorm/deployment-action@v2
id: deployment
with:
token: ${{ secrets.GITHUB_TOKEN }}
environment: stage ${{ matrix.app }}
- name: Dokploy Deployment
if: ${{ steps.set-app-id.outputs.APP_ID != '' }}
uses: benbristow/dokploy-deploy-action@0.0.1
with:
auth_token: ${{ secrets.DOKPLOY_AUTH_TOKEN }}
application_id: ${{ steps.set-app-id.outputs.APP_ID }}
dokploy_url: ${{ secrets.DOKPLOY_URL }}
- name: Update deployment status (success)
if: ${{ steps.set-app-id.outputs.APP_ID != '' && success() }}
uses: chrnorm/deployment-status@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'success'
- name: Update deployment status (failure)
if: ${{ steps.set-app-id.outputs.APP_ID != '' && failure() }}
uses: chrnorm/deployment-status@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'failure'