2021-09-30 11:35:47 -07:00
name : CI/CD
2021-07-05 01:20:27 -07:00
on :
2021-09-30 11:35:47 -07:00
# Triggers the workflow when changes are made to the image on the main branch
2021-07-05 01:20:27 -07:00
push :
branches : [ main ]
2021-09-29 11:37:50 -07:00
paths-ignore : # don't run this workflow if no changes have been made to the docker image
- '.github/**'
- 'docker-compose.yml'
2021-09-30 11:28:42 -07:00
- 'README.md'
2021-07-05 01:20:27 -07:00
pull_request :
branches : [ main ]
2021-09-29 11:37:50 -07:00
paths-ignore : # don't run this workflow if no changes have been made to the docker image
- '.github/**'
- 'docker-compose.yml'
2021-09-30 11:28:42 -07:00
- 'README.md'
2021-07-05 01:20:27 -07:00
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch :
jobs :
2021-09-30 11:35:47 -07:00
ci :
2021-08-01 10:52:36 -07:00
name : Build and push Docker image to Docker Hub
2021-07-05 01:20:27 -07:00
runs-on : ubuntu-latest
steps :
2021-08-01 10:52:36 -07:00
- 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
2021-08-01 11:00:10 -07:00
tags : latest
2021-08-01 16:15:08 -07:00
- 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
2021-08-01 10:52:36 -07:00
- name : Build and push the Docker image
uses : docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with :
context : .
2021-08-01 16:15:08 -07:00
builder : ${{ steps.buildx.outputs.name }}
2021-08-01 16:44:03 -07:00
platforms : linux/amd64,linux/arm64,linux/arm/v7
2021-08-01 10:52:36 -07:00
push : true
tags : ${{ steps.meta.outputs.tags }}
labels : ${{ steps.meta.outputs.labels }}
2021-08-01 11:46:15 -07:00
- name : Docker Hub Description
uses : peter-evans/dockerhub-description@v2
with :
username : ${{ secrets.DOCKERHUB_USERNAME }}
password : ${{ secrets.DOCKERHUB_PASSWORD }}
repository : jafner/5etools-docker
2021-09-30 11:35:47 -07:00
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 }}. Triggered by ${{ EVENT_PAYLOAD.sender }} with ${{ EVENT_PAYLOAD.action }}'