Release #196
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
# https://github.com/docker/build-push-action/blob/master/docs/advanced/tags-labels.md | |
name: Release | |
on: | |
workflow_run: | |
workflows: [ Tests ] | |
types: | |
- completed | |
branches: | |
- main | |
jobs: | |
docker: | |
name: "Docker images" | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Docker meta PHP | |
id: meta-php | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/eventpoints/eventpoint.app-php | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=ref,event=branch | |
type=sha | |
no-cache: true | |
- name: Docker meta Caddy | |
id: meta-caddy | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/eventpoints/eventpoint.app-caddy | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=ref,event=branch | |
type=sha | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Build and push PHP | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
target: php | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-php.outputs.tags }} | |
labels: ${{ steps.meta-php.outputs.labels }} | |
cache-from: type=gha, scope=${{ github.workflow }} | |
cache-to: type=gha, scope=${{ github.workflow }} | |
- name: Build and push Caddy | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
target: caddy | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-caddy.outputs.tags }} | |
labels: ${{ steps.meta-caddy.outputs.labels }} | |
cache-from: type=gha, scope=${{ github.workflow }} | |
cache-to: type=gha, scope=${{ github.workflow }} | |
deploy: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
needs: | |
- docker | |
environment: | |
name: prod | |
url: https://eventpoint.app | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Copy docker-compose template | |
run: cp .deployment/docker-compose.production-template.yml .deployment/docker-compose.yml | |
# Iterate over secrets as JSON and replace possible placeholders | |
# Save output to the file to be processed | |
- name: Prepare docker-compose file | |
run: echo $SECRETS | jq --raw-output 'keys[]' | while read -r secretKey; do cat .deployment/docker-compose.yml | sed "s#__${secretKey}__#$(echo $SECRETS | jq --raw-output .${secretKey} | tr -d '\n\t')#" > .deployment/docker-compose.yml; done | |
env: | |
SECRETS: ${{ toJson(secrets) }} | |
- run: cat .deployment/docker-compose.yml | |
- name: Rsync Docker files | |
uses: burnett01/[email protected] | |
with: | |
switches: -azvr --exclude='docker-compose.production-template.yml' | |
path: ./.deployment/ | |
remote_path: /eventpoint.app | |
remote_host: ${{ secrets.DEPLOY_HOST }} | |
remote_user: ${{ secrets.DEPLOY_USERNAME }} | |
remote_key: ${{ secrets.DEPLOY_PRIVATE_KEY }} | |
- uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USERNAME }} | |
key: ${{ secrets.DEPLOY_PRIVATE_KEY }} | |
script_stop: true | |
script: | | |
cd /eventpoint.app | |
docker-compose pull | |
docker-compose up -d |