mirror of
https://github.com/dsec-hub/dsec-discord-bot.git
synced 2026-09-22 15:53:56 +00:00
deploy.yml runs on the self-hosted VPS runner with passwordless sudo, so a mutable tag on this action is a code-execution path onto that host if the tag is ever moved. Pinned to the commit v4 currently resolves to (11d5960a326750d5838078e36cf38b85af677262), verified against upstream — this is the same code the deploy already runs today, not a version bump. ci.yml is on v7.0.1; the deploy path is deliberately left on v4 so that pinning does not smuggle a major-version change into a workflow whose only test is a live deploy. Raised by Codex review of PR #5 as the one unpinned `uses:` in either workflow. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
53 lines
1.4 KiB
YAML
53 lines
1.4 KiB
YAML
name: Docker Compose Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
# Manual re-run, for redeploying after a rollback or re-creating the
|
|
# workspace .env that the cleanup step below now removes.
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build_and_deploy:
|
|
runs-on: [self-hosted, linux]
|
|
# SEC-01: this gates nothing until required reviewers are configured on the
|
|
# "production" environment itself. See the pull request description.
|
|
environment: production
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
clean: true
|
|
fetch-depth: 1
|
|
|
|
- name: Create environment file
|
|
working-directory: ${{ github.workspace }}
|
|
env:
|
|
DOT_ENV: ${{ secrets.DOT_ENV }}
|
|
run: |
|
|
if [ -z "$DOT_ENV" ]; then
|
|
echo "DOT_ENV secret is missing or empty."
|
|
exit 1
|
|
fi
|
|
|
|
umask 077
|
|
printf '%s\n' "$DOT_ENV" > .env
|
|
|
|
- name: Build and deploy
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
sudo docker compose up -d --build --force-recreate
|
|
echo "Deployment complete."
|
|
|
|
- name: Remove environment file
|
|
if: always()
|
|
working-directory: ${{ github.workspace }}
|
|
run: rm -f .env
|
|
|
|
- name: Clean up old Docker images
|
|
run: sudo docker image prune -f
|