58 lines
1.9 KiB
YAML
58 lines
1.9 KiB
YAML
|
|
# https://docs.gitea.com/next/usage/actions/quickstart
|
|
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
|
|
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context
|
|
|
|
# Configurable with a few commit messages:
|
|
# - [skip-tests] Skip the test stage
|
|
# - [skip-deployment] Skip the deployment stage
|
|
# - [skip-ci] Skip all stages (the whole ci/cd)
|
|
#
|
|
|
|
name: Build Docker and Deploy
|
|
run-name: "[cicd-webapp]: ${{ github.event.head_commit.message }}"
|
|
|
|
on:
|
|
push:
|
|
branches: ['master']
|
|
|
|
|
|
|
|
jobs:
|
|
build_webapp:
|
|
name: Build Docker Container
|
|
runs-on: bfb-cicd-latest
|
|
if: >-
|
|
!contains(github.event.head_commit.message, '[skip-ci]') &&
|
|
!contains(github.event.head_commit.message, '[skip-deployment]')
|
|
steps:
|
|
- run: echo -n "${{ secrets.DOCKER_REG_PASS }}" | docker login registry.blackforestbytes.com -u docker --password-stdin
|
|
- name: Check out code
|
|
uses: actions/checkout@v3
|
|
- run: cd "${{ gitea.workspace }}/webapp" && make clean
|
|
- run: cd "${{ gitea.workspace }}/webapp" && make docker
|
|
- run: cd "${{ gitea.workspace }}/webapp" && make push-docker
|
|
|
|
deploy_webapp:
|
|
name: Deploy to Server
|
|
needs: [build_webapp]
|
|
runs-on: ubuntu-latest
|
|
if: >-
|
|
!cancelled() &&
|
|
!contains(github.event.head_commit.message, '[skip-ci]') &&
|
|
!contains(github.event.head_commit.message, '[skip-deployment]') &&
|
|
needs.build_webapp.result == 'success'
|
|
steps:
|
|
- name: Execute deploy on remote (via ssh)
|
|
uses: appleboy/ssh-action@v1.0.0
|
|
with:
|
|
host: simplecloudnotifier.de
|
|
username: bfb-deploy-bot
|
|
port: 4477
|
|
key: "${{ secrets.SSH_KEY_BFBDEPLOYBOT }}"
|
|
script: cd /var/docker/deploy-scripts/simplecloudnotifier && ./deploy-webapp.sh master "${{ gitea.sha }}" || exit 1
|
|
|
|
|
|
|
|
|