-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (109 loc) · 3.12 KB
/
go.yaml
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
# Copyright (C) 2022 ScyllaDB
name: Images
on:
push:
# Restrict the branches to only those we want to promote from.
branches:
- 'master'
pull_request:
branches:
- '**'
types:
- opened
- edited
- reopened
- synchronize
schedule:
- cron: '0 9 * * *' # daily at 9am
workflow_dispatch: {}
env:
image_registry: quay.io
image_repo_ref: quay.io/${{ github.repository }}
retention_days: 90
defaults:
run:
shell: bash
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
path: ${{ env.git_repo_path }}
- name: Build
run: |
make build REPO=${{ env.image_repo_ref }} --warn-undefined-variables
- name: Save images
run: |
mkdir ~/images/
for image_ref in $( cat .build_state ); do
image_name="$( echo "${image_ref}" | sed -E -e 's/.*:(.*)/\1/' )"
podman save "${image_ref}" | lz4 - ~/images/"${image_name}".tar.lz4
done
- name: Upload image names
uses: actions/upload-artifact@v2
with:
name: build_state
path: ./.build_state
if-no-files-found: error
retention-days: ${{ env.retention_days }}
- name: Upload image artifacts
uses: actions/upload-artifact@v2
with:
name: images
path: ~/images/*.tar.lz4
if-no-files-found: error
retention-days: ${{ env.retention_days }}
promote:
name: Promote images
runs-on: ubuntu-22.04
needs:
- build
if: ${{ github.event_name != 'pull_request' }}
steps:
- uses: actions/checkout@v2
with:
path: ${{ env.git_repo_path }}
- uses: actions/download-artifact@v2
with:
name: build_state
path: ./
- uses: actions/download-artifact@v2
with:
name: images
path: ~/images/
- name: Load image
run: |
for f in ~/images/*.tar.lz4; do
unlz4 "${f}" --to-stdout | podman load
done
- name: Login to Image Registry
uses: docker/login-action@v1
with:
registry: ${{ env.image_repo_ref }}
username: ${{ secrets.IMAGE_REPO_USER }}
password: ${{ secrets.IMAGE_REPO_TOKEN }}
- name: Promote images
run: |
make publish-last-build REPO=${{ env.image_repo_ref }} --warn-undefined-variables
failure-notifications:
name: Failure notifications
runs-on: ubuntu-22.04
needs:
- build
- promote
if: ${{ failure() && github.event_name != 'pull_request' }}
steps:
- name: Report failures to Slack
if: ${{ always() }}
working-directory: .
run: |
# We have to avoid printing the secret to logs.
set +x
curl -X POST -H 'Content-type: application/json' --data @<( cat <<-EOF
{
"text": ":warning: CI workflow \"${{ github.workflow }}\" triggered on \"${{ github.event_name }}\" event from ${{ github.ref }} (${{ github.sha }}) failed!\n:fire_extinguisher: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for details.:fire:"
}
EOF
) '${{ secrets.SLACK_WEBHOOK_URL }}'