-
Notifications
You must be signed in to change notification settings - Fork 5
111 lines (92 loc) · 2.89 KB
/
ci-master.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
on:
push:
branches:
- master
- feature/containerize
workflow_dispatch:
name: ci-master
env:
REGISTRY: ghcr.io
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for mkdocs-git-authors-plugin
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-arch
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Build site
run: mkdocs build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: wiki
path: site/*
retention-days: 7
if-no-files-found: error
containerize:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
Dockerfile
requirements.txt
mkdocs.yml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: wiki
path: site
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/wiki
flavor: |
latest=false
tags: |
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }}
type=raw,value=latest,enable=${{ steps.latest-tag.outputs.tag == github.ref_name }}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-latest
needs: containerize
if: ${{ github.ref_type == 'branch' && github.ref_protected && github.event_name != 'pull_request' }}
environment: production
steps:
- name: Call deployment webhook
shell: bash
env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
run: |
curl -X POST -d "" "$WEBHOOK_URL"