Repository navigation
67 lines (55 loc) · 1.54 KB
/
Copy pathdeploy.yml
File metadata and controls
67 lines (55 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: deploy
# Auto-deploy to the self-hosted runner on push to main
on:
push:
branches: [main]
workflow_dispatch:
# Don't let two deploys overlap; don't cancel one in flight.
concurrency:
group: deploy
cancel-in-progress: false
# Least privilege by default; build job widens to packages: write for GHCR.
permissions:
contents: read
env:
IMAGE: ghcr.io/ofbirds/difflab
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v7
with:
context: .
push: true
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build
runs-on: [self-hosted]
permissions:
contents: read
packages: read
steps:
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Pull image
working-directory: ${{ vars.DEPLOY_DIR }}
run: docker compose pull
- name: Deploy
working-directory: ${{ vars.DEPLOY_DIR }}
run: docker compose up -d --wait
- name: Prune dangling images
run: docker image prune -f