Skip to content

Merge pull request #42 from tangram-orchestre/merge-back-master #137

Merge pull request #42 from tangram-orchestre/merge-back-master

Merge pull request #42 from tangram-orchestre/merge-back-master #137

Workflow file for this run

name: CI/CD
on:
push:
branches:
- master
- develop
# Ensure deployments are sequential
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
DOCKER_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/showcase-website
MARKER_BRANCH: ${{ github.ref == 'refs/heads/master' && 'production' || 'staging' }}
DEPLOY_SOURCE_DIR: ${{ github.ref == 'refs/heads/master' && 'deploy/production/' || 'deploy/staging/' }}
DEPLOY_TARGET_DIR: ${{ github.ref == 'refs/heads/master' && '/opt/services/' || '/opt/services-staging/' }}
jobs:
deploy:
name: Build and Deploy
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect Changes
id: changes
uses: ./.github/actions/detect-changes
with:
ref_branch: ${{ env.MARKER_BRANCH }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Showcase Website
if: vars.FORCE_BUILD == 'true' || steps.changes.outputs.showcase-website == 'true'
uses: ./.github/actions/build-showcase-website
with:
DOCKER_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/showcase-website
TAG: ${{ env.MARKER_BRANCH }}
- name: Sync dir to server
uses: burnett01/rsync-deployments@7.0.1
with:
switches: -avzr --delete --exclude='.env'
path: ${{ env.DEPLOY_SOURCE_DIR }}
remote_path: ${{ env.DEPLOY_TARGET_DIR }}
remote_host: tangram-orchestre.fr
remote_user: ${{ secrets.DEPLOY_USERNAME }}
remote_key: ${{ secrets.DEPLOY_KEY }}
- name: Update services
if: vars.SKIP_DEPLOY != 'true'
uses: appleboy/ssh-action@v1.0.3
with:
host: tangram-orchestre.fr
username: ${{ secrets.DEPLOY_USERNAME }}
key: ${{ secrets.DEPLOY_KEY }}
script: ${{ env.DEPLOY_TARGET_DIR }}/update.sh
- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.UPDATE_BRANCH_KEY }}
- name: Update marker branch
run: |
git push --force origin HEAD:${{ env.MARKER_BRANCH }}