89 lines
2.9 KiB
YAML
89 lines
2.9 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
# Triggers the workflow when changes are made to the image on the main branch
|
|
push:
|
|
branches: [ main ]
|
|
paths-ignore: # don't run this workflow if no changes have been made to the docker image
|
|
- '.github/**'
|
|
- 'docker-compose.yml'
|
|
- 'README.md'
|
|
pull_request:
|
|
branches: [ main ]
|
|
paths-ignore: # don't run this workflow if no changes have been made to the docker image
|
|
- '.github/**'
|
|
- 'docker-compose.yml'
|
|
- 'README.md'
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
ci:
|
|
name: Build and push Docker image to Docker Hub
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Log into Docker Hub
|
|
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
|
with:
|
|
images: jafner/5etools-docker
|
|
tags: latest
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@master
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@master
|
|
|
|
- name: Build and push the Docker image
|
|
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
|
with:
|
|
context: .
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Docker Hub Description
|
|
uses: peter-evans/dockerhub-description@v2
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
repository: jafner/5etools-docker
|
|
cd:
|
|
if: ${{ false }} # disable for now
|
|
name: Deploy new image to server
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Updating and restarting service on host via SSH
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.SITE_HOST }}
|
|
username: ${{ secrets.SITE_USERNAME }}
|
|
key: ${{ secrets.SITE_KEY }}
|
|
port: ${{ secrets.SITE_PORT }}
|
|
script: |
|
|
cd /root
|
|
docker pull jafner/5etools-docker:latest
|
|
docker-compose down
|
|
docker-compose up -d
|
|
|
|
- name: Sending Discord notification
|
|
env:
|
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
|
uses: Ilshidur/action-discord@master
|
|
with:
|
|
args: 'The project {{ EVENT_PAYLOAD.repository.full_name }} has been deployed to ${{ secrets.SITE_HOST }}.' |