feat(ci): add auto-deploy workflow via brencher action
Adds .github/workflows/deploy.yml that triggers on PR approval (or manual dispatch) and invokes the brencher reusable action from admin/brencher to: 1. Build the reverseproxy image and push it to registry.rudolf.keenetic.link with an auto-<sha> tag. 2. SSH to the swarm manager, reset the deploy branch (deploy/torrserv_proxy) to origin, and run 'docker stack deploy --prune --resolve-image-always' against docker-compose.yml. First end-to-end pilot of the auto-deploy design (see admin/brencher#24 for context).
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
name: build-and-deploy
|
||||
|
||||
on:
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'pull_request_review' &&
|
||||
github.event.review.state == 'approved' &&
|
||||
github.event.review.author_association == 'OWNER')
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Build, push, deploy
|
||||
uses: admin/brencher/.github/actions/brencher@main
|
||||
with:
|
||||
registry: gitea.rudolf.keenetic.link
|
||||
image_name: admin/reverseproxy
|
||||
stack_name: torrserv_proxy
|
||||
compose_path: docker-compose.yml
|
||||
swarm_manager_host: ${{ secrets.SWARM_MANAGER_HOST }}
|
||||
swarm_ssh_user: ${{ secrets.SWARM_SSH_USER }}
|
||||
swarm_ssh_key: ${{ secrets.SWARM_SSH_KEY }}
|
||||
registry_username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
deploy_branch: deploy/torrserv_proxy
|
||||
|
||||
- name: Comment on PR
|
||||
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
|
||||
uses: marocchino/sticky-pull-request-comment@v2
|
||||
with:
|
||||
header: brencher-deploy
|
||||
message: |
|
||||
✅ Deployed `torrserv_proxy` at `${{ github.event.pull_request.head.sha || github.sha }}`
|
||||
- triggered by: @${{ github.event.review.user.login }}
|
||||
Reference in New Issue
Block a user