Skip to content

Updated intro, since the pandemic is over now. (#61) #43

Updated intro, since the pandemic is over now. (#61)

Updated intro, since the pandemic is over now. (#61) #43

Workflow file for this run

name: Deploy
on:
push:
branches: [ master ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repo files
uses: actions/checkout@v2
# https://github.com/docker/setup-qemu-action
# QEMU is used for building multi-platform
# docker images (amd64, arm64)
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}
# Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:src"
platforms: |-
linux/amd64
linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pull: true
cache-from: type=gha
cache-to: type=gha
# Pull this newly created package on an sshb host,
# restart service and prune old docker images.
- name: Deploy package to server
uses: appleboy/ssh-action@master
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
envs: GITHUB_USERNAME,GITHUB_TOKEN
script: |
docker login -u $GITHUB_USERNAME -p $GITHUB_TOKEN ${{ env.REGISTRY }}
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master
docker-compose --file ~/docker_apps/docker-compose.yaml up -d
docker image prune -a -f --filter "until=240h"