-
Notifications
You must be signed in to change notification settings - Fork 96
161 lines (139 loc) · 5.7 KB
/
rabbitmq-oci.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
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
151
152
153
154
155
156
157
158
159
160
161
# https://github.com/marketplace/actions/build-and-push-docker-images
name: RabbitMQ OCI
on:
pull_request:
workflow_dispatch:
inputs:
rabbitmq_ref:
description: The branch, tag or commit of rabbitmq-server to use
default: main
jobs:
build-publish-dev:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image_tag_suffix: otp-max-bazel
otp_version_id: 26_1
steps:
- name: Checkout Ra
uses: actions/checkout@v3
with:
path: ra
- name: Inject the git sha as the ra version
working-directory: ra
run: |
sed -i"_orig" "/vsn,/ s/2\\.[0-9]\\.[0-9]/${{ github.event.pull_request.head.sha || github.sha }}/" src/ra.app.src
- name: Checkout RabbitMQ
uses: actions/checkout@v3
with:
repository: rabbitmq/rabbitmq-server
ref: ${{ github.event.inputs.rabbitmq_ref }}
path: rabbitmq-server
- name: Load RabbitMQ Version Info
id: load-rabbitmq-info
working-directory: rabbitmq-server
run: |
echo "RABBITMQ_SHA=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "RABBITMQ_REF=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
- name: Mount Bazel Cache
uses: actions/cache@v1
with:
path: "/home/runner/repo-cache/"
key: repo-cache
- name: Configure Bazel
working-directory: rabbitmq-server
run: |
if [ -n "${{ secrets.BUILDBUDDY_API_KEY }}" ]; then
cat << EOF >> user.bazelrc
build:buildbuddy --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}
EOF
fi
cat << EOF >> user.bazelrc
build:buildbuddy --build_metadata=ROLE=CI
build:buildbuddy --build_metadata=VISIBILITY=PRIVATE
build:buildbuddy --repository_cache=/home/runner/repo-cache/
build:buildbuddy --color=yes
build:buildbuddy --disk_cache=
build:buildbuddy --remote_download_toplevel
build --@io_bazel_rules_docker//transitions:enable=false
EOF
- name: Check OTP/Elixir versions used in RBE
id: load-info
working-directory: rabbitmq-server
run: |
bazelisk build :otp_version :elixir_version \
--config=rbe \
--platforms=//bazel/platforms:erlang_linux_${{ matrix.otp_version_id }}_platform
echo "otp=$(cat bazel-bin/otp_version.txt)" >> $GITHUB_OUTPUT
echo "elixir=$(cat bazel-bin/elixir_version.txt)" >> $GITHUB_OUTPUT
- name: Configure OTP & Elixir
uses: erlef/[email protected]
with:
otp-version: ${{ steps.load-info.outputs.otp }}
elixir-version: ${{ steps.load-info.outputs.elixir }}
- name: Configure the ra override for this ra
working-directory: rabbitmq-server
run: |
cat << EOF >> user.bazelrc
build --override_repository=rules_erlang~~erlang_package~ra=${{ github.workspace }}/ra
EOF
- name: Configure otp for the OCI image
working-directory: rabbitmq-server
run: |
sudo npm install --global --silent @bazel/buildozer
buildozer 'set tars ["@otp_src_${{ matrix.otp_version_id }}//file"]' \
//packaging/docker-image:otp_source
- name: Build
working-directory: rabbitmq-server
run: |
bazelisk build //packaging/docker-image:rabbitmq \
--config=buildbuddy
- name: Load
working-directory: rabbitmq-server
run: |
bazelisk run //packaging/docker-image:rabbitmq \
--config=buildbuddy
- name: Check for Push Credentials
id: authorized
run: |
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ]; then
echo "PUSH=true" >> $GITHUB_OUTPUT
else
echo "PUSH=false" >> $GITHUB_OUTPUT
fi
- name: Login to DockerHub
if: steps.authorized.outputs.PUSH == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Tag and Push
if: steps.authorized.outputs.PUSH == 'true'
working-directory: rabbitmq-server
run: |
RABBIT_REF=${{ steps.load-rabbitmq-info.outputs.RABBITMQ_REF }}
RABBIT_SHA=${{ steps.load-rabbitmq-info.outputs.RABBITMQ_SHA }}
RA_SHA=${{ github.event.pull_request.head.sha || github.sha }}
RA_ABBREV=ra-${RA_SHA:0:7}
TAG_1=rabbitmq-${RABBIT_REF}-${RA_ABBREV}-${{ steps.load-info.outputs.otp }}
TAG_2=rabbitmq-${RABBIT_REF}-${RA_ABBREV}-${{ matrix.image_tag_suffix }}
TAG_3=rabbitmq-${RABBIT_SHA:0:7}-${RA_ABBREV}-${{ steps.load-info.outputs.otp }}
TAG_4=rabbitmq-${RABBIT_SHA:0:7}-${RA_ABBREV}-${{ matrix.image_tag_suffix }}
echo "Will tag with ${TAG_1}"
echo "Will tag with ${TAG_2}"
echo "Will tag with ${TAG_3}"
echo "Will tag with ${TAG_4}"
docker tag bazel/packaging/docker-image:rabbitmq \
pivotalrabbitmq/rabbitmq:${TAG_1}
docker tag bazel/packaging/docker-image:rabbitmq \
pivotalrabbitmq/rabbitmq:${TAG_2}
docker tag bazel/packaging/docker-image:rabbitmq \
pivotalrabbitmq/rabbitmq:${TAG_3}
docker tag bazel/packaging/docker-image:rabbitmq \
pivotalrabbitmq/rabbitmq:${TAG_4}
docker push pivotalrabbitmq/rabbitmq:${TAG_1}
docker push pivotalrabbitmq/rabbitmq:${TAG_2}
docker push pivotalrabbitmq/rabbitmq:${TAG_3}
docker push pivotalrabbitmq/rabbitmq:${TAG_4}