chore(release): 5.2.0 #15
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
name: deploy | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- 'README.md' | |
- 'CHANGELOG.md' | |
- 'LICENSE.md' | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
docker-build: | |
# We can skip deployment by adding [skip] in the commit body | |
if: "!contains(github.event.head_commit.message, '[skip]')" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up dockertags | |
run: | | |
echo "dockertags=digisquad/cssninja.fresh-demo:latest" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
timeout-minutes: 60 | |
with: | |
push: true | |
tags: ${{ env.dockertags }} | |
cache-from: type=registry,ref=${{ env.dockertags }} | |
cache-to: type=inline | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [docker-build] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Prepare | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script_stop: true | |
script: mkdir -p ${{ secrets.HOST_DIRECTORY }} | |
- name: Publish | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: docker-compose.yml | |
target: ${{ secrets.HOST_DIRECTORY }} | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script_stop: true | |
script: | | |
cd ${{ secrets.HOST_DIRECTORY }} | |
docker-compose pull | |
docker-compose up -d --force-recreate --remove-orphans |