This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/checkout](https://github.com/actions/checkout) | action | major | `v4` -> `v5` | | [actions/checkout](https://github.com/actions/checkout) | action | major | `v4.3.0` -> `v5.0.0` | --- ### Release Notes <details> <summary>actions/checkout (actions/checkout)</summary> ### [`v5`](https://github.com/actions/checkout/compare/v4...v5) [Compare Source](https://github.com/actions/checkout/compare/v4...v5) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS42MS4xIiwidXBkYXRlZEluVmVyIjoiNDEuNjUuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsidHlwZS9kZXBlbmRlbmNpZXMiXX0=--> Reviewed-on: #29 Co-authored-by: Renovate [BOT] <renovate-bot@git.tainton.uk> Co-committed-by: Renovate [BOT] <renovate-bot@git.tainton.uk>
97 lines
3.4 KiB
YAML
97 lines
3.4 KiB
YAML
name: Docker Compose Deploy Stack
|
|
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
DEPLOY_HOST:
|
|
required: true
|
|
type: string
|
|
DEPLOY_USERNAME:
|
|
required: true
|
|
type: string
|
|
DEPLOY_SSHKEY:
|
|
required: true
|
|
type: string
|
|
DEPLOY_PORT:
|
|
required: true
|
|
type: string
|
|
PUSHOVER_USER_TOKEN:
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: "[ON RUNNER] Notify Build Start"
|
|
uses: https://git.tainton.uk/actions/pushover-action@v1.1.3
|
|
env:
|
|
PUSHOVER_APP_TOKEN: ${{ secrets.PUSHOVER_APP_TOKEN }}
|
|
PUSHOVER_USER_TOKEN: ${{ secrets.PUSHOVER_USER_TOKEN }}
|
|
with:
|
|
message: "Deploying stack ${{ gitea.repository }}"
|
|
title: 'Stack Deployment Started'
|
|
url: "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
|
|
url_title: 'View Logs'
|
|
|
|
- name: "[ON RUNNER] Checkout the repo"
|
|
uses: actions/checkout@v5
|
|
|
|
- name: "[ON RUNNER] Set project variables"
|
|
run: |
|
|
projectname="${{ gitea.event.repository.name }}"
|
|
echo "project_name=$projectname" >> $GITEA_ENV
|
|
echo "project_folder=/home/${{ secrets.DEPLOY_USERNAME }}/$projectname" >> $GITEA_ENV
|
|
|
|
- name: "[ON RUNNER] Create env file"
|
|
run: |
|
|
rm -f ".env"
|
|
touch ".env"
|
|
echo "$ALLVARS" | jq -r '. | to_entries[] | select(.key | startswith("DC_")) | .key + "=" + .value' >> ".env"
|
|
echo "$ALLSECRETS" | jq -r '. | to_entries[] | select(.key | startswith("DC_")) | .key + "=" + .value' >> ".env"
|
|
env:
|
|
ALLVARS: ${{ toJSON(vars) }}
|
|
ALLSECRETS: ${{ toJSON(secrets) }}
|
|
|
|
- name: "[ON HOST] Make directory if not exists"
|
|
uses: appleboy/ssh-action@v1.2.2
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USERNAME }}
|
|
key: ${{ secrets.DEPLOY_SSHKEY }}
|
|
port: ${{ secrets.DEPLOY_PORT }}
|
|
script: |
|
|
mkdir -p ${{ env.project_folder }}
|
|
|
|
- name: "[ON HOST] SCP files to host"
|
|
uses: appleboy/scp-action@v1.0.0
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USERNAME }}
|
|
port: ${{ secrets.DEPLOY_PORT }}
|
|
key: ${{ secrets.DEPLOY_SSHKEY }}
|
|
source: "./compose.yaml,./.env"
|
|
target: "${{ env.project_folder }}/"
|
|
|
|
- name: "[ON HOST] Deploy Stack"
|
|
uses: appleboy/ssh-action@v1.2.2
|
|
with:
|
|
host: ${{ secrets.DEPLOY_HOST }}
|
|
username: ${{ secrets.DEPLOY_USERNAME }}
|
|
key: ${{ secrets.DEPLOY_SSHKEY }}
|
|
port: ${{ secrets.DEPLOY_PORT }}
|
|
script: |
|
|
cd ${{ env.project_folder }}
|
|
docker compose --env-file .env up --detach
|
|
|
|
- name: "[ON RUNNER] Notify Build End"
|
|
uses: https://git.tainton.uk/actions/pushover-action@v1.1.3
|
|
env:
|
|
PUSHOVER_APP_TOKEN: ${{ secrets.PUSHOVER_APP_TOKEN }}
|
|
PUSHOVER_USER_TOKEN: ${{ secrets.PUSHOVER_USER_TOKEN }}
|
|
with:
|
|
message: "Deployed stack ${{ gitea.repository }}"
|
|
title: 'Stack Deployment ${{ job.status }}'
|
|
url: "${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
|
|
url_title: 'View Logs'
|