Try when nothing has to be deployed #92
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: 'Deploy to staging' | |
env: | |
FONTAWESOME_PACKAGE_TOKEN: ${{ secrets.FONTAWESOME_PACKAGE_TOKEN }} | |
REGISTRY: ghcr.io | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
define-matrix: | |
name: 'Gather affected projects' | |
runs-on: ubuntu-latest | |
outputs: | |
projects: ${{ steps.projects.outputs.projects }} | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
- name: Set up Moon Toolchain | |
uses: 'moonrepo/setup-toolchain@v0' | |
- run: moon query tasks --id staging-dokploy-compose-deploy --affected --downstream deep --log trace | |
- name: Define Projects | |
id: projects | |
run: | | |
echo "projects=$(moon query tasks --id staging-dokploy-compose-deploy --affected --downstream deep | awk 'NR % 2 == 1 {print "\"" $1 "\""}' | paste -sd, - | sed 's/^/\[/; s/$/\]/')" >> "$GITHUB_OUTPUT" | |
build-and-push: | |
if: ${{ needs.define-matrix.outputs.projects != '[]' && needs.define-matrix.outputs.projects != '' }} | |
name: '${{ matrix.projects }} | Build and push docker image' | |
needs: define-matrix | |
continue-on-error: true | |
strategy: | |
fail-fast: false | |
matrix: | |
projects: ${{ fromJSON(needs.define-matrix.outputs.projects) }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
- name: Set up Moon Toolchain | |
uses: 'moonrepo/setup-toolchain@v0' | |
with: | |
auto-install: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push docker images | |
run: 'moon ci ${{ matrix.projects }}:staging-docker-push' | |
deploy: | |
name: '${{ matrix.projects }} | Deploy' | |
runs-on: ubuntu-latest | |
needs: | |
- define-matrix | |
- build-and-push | |
strategy: | |
fail-fast: false | |
matrix: | |
projects: ${{ fromJSON(needs.define-matrix.outputs.projects) }} | |
steps: | |
- uses: 'actions/checkout@v4' | |
with: | |
fetch-depth: 0 | |
- name: Set up Moon Toolchain | |
uses: 'moonrepo/setup-toolchain@v0' | |
- name: 'Redeploy from Dokploy on VPS' | |
env: | |
DOKPLOY_API_TOKEN: ${{ secrets.DOKPLOY_API_TOKEN }} | |
DOKPLOY_API_URL: ${{ secrets.DOKPLOY_API_URL }} | |
run: 'moon ci ${{ matrix.projects }}:staging-dokploy-compose-deploy' |