forked from gatekeeper/gatekeeper-operator
-
Notifications
You must be signed in to change notification settings - Fork 4
106 lines (93 loc) · 3.32 KB
/
release.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
name: Build and release images
on:
push:
branches:
- main
- release-[0-9]+.[0-9]+
tags:
- "v*" # tags matching v*, i.e. v0.0.1, v1.0.0-rc.0
jobs:
build:
name: Image build and push
outputs:
ff: ${{ steps.ff.outputs.ff }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Set Up Go to Install OPM
uses: actions/setup-go@v5
with:
go-version-file: go.mod
# Issue ref: https://github.com/actions/checkout/issues/290.
- name: Extract Non-Annotated Version Tag
run: |
echo "GIT_VERSION=$(git describe --tags --match='v*' --always --dirty)" >> ${GITHUB_ENV}
- name: Verify release manifest
if: ${{ github.ref_type == 'tag' }}
run: |
make release
git diff --exit-code ./deploy/gatekeeper-operator.yaml
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
driver-opts: image=moby/buildkit:v0.8-beta
- uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build and Push Images
run: |
echo "::group::gatekeeper-operator"
make docker-build
make docker-push
echo "::endgroup::"
echo "::group::gatekeeper-operator-bundle"
make bundle-build
make bundle-push
echo "::endgroup::"
echo "::group::gatekeeper-operator-bundle-index"
make bundle-index-build
make bundle-index-push
echo "::endgroup::"
- name: Detect fast-forward requirement
id: ff
if: ${{ github.ref_type == 'tag' }}
run: |
if [[ "${GITHUB_SHA}" == "$(git rev-parse origin/main)" ]]; then
echo "Commit ${GITHUB_SHA} tagged as ${{ github.ref_name }} detected as latest commit on main. Enabling fast-forwarding ..."
echo "ff=true" >> $GITHUB_OUTPUT
fi
ff:
name: Fast forward from main to latest release branch
runs-on: ubuntu-latest
needs: [build]
if: ${{ needs.build.outputs.ff == 'true' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Fast-forward main to latest release
run: |
RELEASE_BRANCH="release-$(cut -d '.' -f 1,2 VERSION)"
git checkout ${RELEASE_BRANCH} || git checkout -b ${RELEASE_BRANCH}
git merge --ff-only origin/main
git push origin ${RELEASE_BRANCH}
- name: Slack failure report
uses: slackapi/[email protected]
if: ${{ failure() }}
env:
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SLACK_WEBHOOK_URL: ${{ secrets.CODE_HEALTH_SLACK_WEBHOOK }}
with:
payload: |
{"blocks": [{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":failed: Gatekeeper Operator fast-forwarding failed: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View workflow run>"
}
}]}