-
Notifications
You must be signed in to change notification settings - Fork 10
131 lines (128 loc) · 4.96 KB
/
build.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
name: build
on:
push:
branches:
- main
workflow_dispatch:
inputs:
push:
description: Push to Docker hub after build is complete.
default: true
type: boolean
services:
description: Space delimited string of services to build. If empty, all will be built.
type: string
schedule:
- cron: '0 0 * * 6'
env:
TASK_VERSION: v3.29.1
TASK_CHECKSUM: e411770abf73d5e094100ab7a1c8278f35b591ecadbfd778200b6b2ad1ee340b
# If this changes, also update the if on the docs job. We unfortunately can't
# use env.PUSH in the if there.
PUSH: ${{ (inputs.push || github.event_name == 'schedule' || github.event_name == 'push') && 'true' || 'false' }}
jobs:
matrix:
name: Create service matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
run: .github/workflows/gha-matrix.sh ${{ inputs.services }} >> $GITHUB_OUTPUT
build:
name: Build service
needs: matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
fail-fast: false
steps:
# v1.3.1
- uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
# Some of our services need a lot of free disk. We run this action to
# free up some disk space, however it is slow, so we conditionally do
# this only on those services that need it.
if: matrix.service == 'opensearch' || matrix.service == 'dynamodb'
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get update
&& sudo apt-get install -y eatmydata
&& sudo ln -snf /usr/bin/eatmydata /usr/local/bin/apt-get
&& sudo apt-get install -y parallel jq curl
&& curl -L -o /tmp/task_linux_amd64.deb https://github.com/go-task/task/releases/download/${{ env.TASK_VERSION }}/task_linux_amd64.deb
&& sha256sum /tmp/task_linux_amd64.deb | grep -q ${{ env.TASK_CHECKSUM }}
&& sudo dpkg -i /tmp/task_linux_amd64.deb
&& sudo apt-get clean
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
# Expose the actions cache url and token.
# https://github.com/tonistiigi/go-actions-cache/blob/master/api.md#authentication
name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v2
- run: task -- ${{ matrix.service }}
id: task
docs:
name: Generate docs
needs: build
runs-on: ubuntu-latest
# If the push portion of this logic changes, change env.PUSH logic as well.
if: always() && (inputs.push || github.event_name == 'schedule' || github.event_name == 'push')
steps:
- name: Install dependencies
run: sudo apt-get update
&& sudo apt-get install -y curl rsync
&& curl -L -o /tmp/task_linux_amd64.deb https://github.com/go-task/task/releases/download/${{ env.TASK_VERSION }}/task_linux_amd64.deb
&& sha256sum /tmp/task_linux_amd64.deb | grep -q ${{ env.TASK_CHECKSUM }}
&& sudo dpkg -i /tmp/task_linux_amd64.deb
&& sudo apt-get clean
&& sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
- name: Checkout TugboatQA/images
uses: actions/checkout@v3
with:
path: images
- name: Checkout TugboatQA/dockerfiles
uses: actions/checkout@v3
with:
repository: TugboatQA/dockerfiles
path: dockerfiles
- name: Generate docs
working-directory: images
run: task generate && task prepare-docs
- name: Sync docs
run: rsync -av
--delete
--exclude .git
--exclude LICENSE
--exclude README.md
--exclude MANIFEST_LIST
--exclude '*/built'
images/images/ dockerfiles/
- name: Configure SSH Agent
uses: webfactory/ssh-agent@d4b9b8ff72958532804b70bbe600ad43b36d5f2e
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Commit and push
working-directory: dockerfiles
run: |
test "$PUSH" != "1" \
&& test "$PUSH" != "true" \
&& echo "Skipping push: PUSH=$PUSH" \
&& exit 0 \
|| echo "Pushing to TugboatQA/dockerfiles: PUSH=$PUSH"
git config user.name github-actions
git config user.email github-actions@github.com
git add . && git diff --cached --exit-code || (git commit -m "$GITHUB_RUN_NUMBER" && git push)