Skip to content

Release 5.7.0

Release 5.7.0 #32

Workflow file for this run

name: Deploy Docker image
on:
push:
tags:
- v*-alpha*
release:
types:
- published
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'release' && 'production' || 'staging' }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
build-args: |
VERSION=${{ github.ref_name }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Install and run Docker image on the server
uses: fifsky/ssh-action@master
with:
command: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
contid=$(docker ps | grep ${{ env.IMAGE_NAME }} | cut -d' ' -f1); if [ ! -z $contid ]; then docker stop $contid; fi
docker run -d -e GTAG_ID=${{ secrets.GTAG_ID }} -p ${{ vars.DOCKER_EXPOSED_PORT }}:8000 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
host: ${{ vars.DEPLOY_HOST }}
port: ${{ vars.DEPLOY_PORT }}
user: ${{ vars.DEPLOY_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY}}
- name: Purge Cloudflare cache
uses: fjogeleit/http-request-action@v1
if: ${{ github.event_name == 'release' }}
with:
url: https://api.cloudflare.com/client/v4/zones/${{ secrets.CLOUDFLARE_ZONE }}/purge_cache
method: POST
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.CLOUDFLARE_TOKEN }}
data: '{"purge_everything": true}'