forked from SUNET/vc
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (88 loc) · 3.6 KB
/
pr-rc-build.yaml
File metadata and controls
100 lines (88 loc) · 3.6 KB
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
name: pr-rc-build
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
jobs:
rc-build:
runs-on: ubuntu-latest
outputs:
rc_tag: ${{ steps.rc_tag.outputs.rc_tag }}
version: ${{ steps.rc_tag.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Generate RC tag
id: rc_tag
run: |
VERSION=$(cat VERSION | tr -d '[:space:]')
SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-8)
PR_NUMBER=${{ github.event.pull_request.number }}
RC_TAG="${VERSION}-rc.${PR_NUMBER}.${SHORT_SHA}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "rc_tag=${RC_TAG}" >> $GITHUB_OUTPUT
echo "RC tag: ${RC_TAG}"
- name: Install Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: go.mod
cache-dependency-path: "**/*.sum"
- name: Install deb packages
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
with:
packages: protobuf-compiler
version: 1.0
- name: Install go packages
run: |
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
export PATH="$PATH:$(go env GOPATH)/bin"
go install github.com/swaggo/swag/cmd/swag@latest
- name: Build
run: make build
- name: Comment RC tag on PR
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const rcTag = '${{ steps.rc_tag.outputs.rc_tag }}';
const version = '${{ steps.rc_tag.outputs.version }}';
const body = `### 🏗️ Release Candidate Build
**RC Tag:** \`${rcTag}\`
**Target Release:** \`v${version}\`
**Commit:** \`${{ github.event.pull_request.head.sha }}\`
#### Docker Images
| Service | Image |
|---------|-------|
| apigw | \`docker.sunet.se/iam_vc/apigw:${rcTag}\` |
| verifier | \`docker.sunet.se/iam_vc/verifier:${rcTag}\` |
| registry | \`docker.sunet.se/iam_vc/registry:${rcTag}\` |
| mockas | \`docker.sunet.se/iam_vc/mockas:${rcTag}\` |
| issuer | \`docker.sunet.se/iam_vc/issuer:${rcTag}\` |
| ui | \`docker.sunet.se/iam_vc/ui:${rcTag}\` |
> Deploy with: \`VERSION=${rcTag} docker compose pull\``;
// Find and update existing RC comment or create new one
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Release Candidate Build')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}