-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (124 loc) · 4.6 KB
/
ci.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: build docker image
on:
repository_dispatch:
push:
branches:
- master
paths-ignore:
- '.gitignore'
- '.dockerignore'
- 'README.md'
- 'LICENSE'
env:
REGISTRY: ghcr.io
jobs:
docker_build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: docker_img_changes
with:
filters: |
src:
- 'Dockerfile'
- 'build.py'
# the Makefile is the source of truth
- name: set docker image info from Makefile
if: steps.docker_img_changes.outputs.src == 'true'
id: info
shell: bash
run: |
set -x
IMAGE_NAME=$(make print-image-name)
IMAGE_VERSION=$(make print-image-version)
echo "::set-output name=IMAGE_NAME::${IMAGE_NAME}"
echo "::set-output name=IMAGE_VERSION::${IMAGE_VERSION}"
- name: check info ok
if: steps.docker_img_changes.outputs.src == 'true'
run: |
IMAGE_NAME="${{ steps.info.outputs.IMAGE_NAME }}"
printf 'IMAGE_NAME is: <<%s>>\n' "${IMAGE_NAME}"
if [ -z ${IMAGE_NAME} ]; then
false
fi
IMAGE_VERSION="${{ steps.info.outputs.IMAGE_VERSION }}"
printf 'IMAGE_VERSION is: <<%s>>\n' "${IMAGE_VERSION}"
if [ -z ${IMAGE_VERSION} ]; then
false
fi
- name: Log in to github Container registry
if: steps.docker_img_changes.outputs.src == 'true' && github.event_name != 'pull_request'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# not sure this is actually needed
- name: Set up Docker Buildx
if: steps.docker_img_changes.outputs.src == 'true'
uses: docker/setup-buildx-action@v1
- name: Extract metadata (tags, labels) for Docker
if: steps.docker_img_changes.outputs.src == 'true'
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: debug - dump metadata
if: steps.docker_img_changes.outputs.src == 'true'
shell: bash
run: |
printf 'tags are: <<%s>>\n' "${{ steps.meta.outputs.tags }}"
printf 'tags labels are: <<%s>>\n' "${{ steps.meta.outputs.labels }}"
printf 'repos is: <<%s>>\n' "${{ github.repository }}"
# really, this is just using info that _mostly_
# could've been got from makefile.
# But some is from CI environment.
- name: Build Docker image
if: steps.docker_img_changes.outputs.src == 'true'
shell: bash
run: |
set -x
export IMAGE_NAME="${{ steps.info.outputs.IMAGE_NAME }}"
export GH_IMAGE_ID="${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}"
export IMAGE_VERSION="${{ steps.info.outputs.IMAGE_VERSION }}"
export REPO_OWNER="${{ github.repository_owner }}"
echo "${{ steps.meta.outputs.labels }}" > oc_labels
# "
python3 ./build.py
- name: push to github registry
if: github.event_name != 'pull_request' && steps.docker_img_changes.outputs.src == 'true'
shell: bash
run: |
set -x
set -euo pipefail
GH_IMAGE_ID=${{ env.REGISTRY }}/${{ github.repository }}/${{ steps.info.outputs.IMAGE_NAME }}
IMAGE_VERSION=${{ steps.info.outputs.IMAGE_VERSION }}
docker push ${GH_IMAGE_ID}:${IMAGE_VERSION}
docker tag ${GH_IMAGE_ID}:${IMAGE_VERSION} ${GH_IMAGE_ID}:latest
docker push ${GH_IMAGE_ID}:latest
publish:
runs-on: ubuntu-20.04
needs: docker_build
steps:
- uses: actions/checkout@v2
- name: Log in to github Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build site
shell: bash
run: |
set -x
make IMG=${{ env.REGISTRY }}/${{ github.repository }}/phlummox-blog:latest \
build
ls -alt
sudo ls -alt `sudo find out -type f | sort`
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out/_site
force_orphan: true