Skip to content

Commit 351dd80

Browse files
authored
Merge pull request #11 from jotak/pre-merge-image
NETOBSERV-229 create pre-merge image on PR via action
2 parents e397ca1 + 0fc8c22 commit 351dd80

File tree

3 files changed

+74
-1
lines changed

3 files changed

+74
-1
lines changed

.github/workflows/push_image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: push to quay.io
1+
name: Build and push to quay.io
22
on:
33
push:
44
branches: [ main ]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build and push PR image to quay.io
2+
on:
3+
pull_request_target:
4+
types: [labeled]
5+
6+
env:
7+
REGISTRY_USER: netobserv+github_ci
8+
REGISTRY: quay.io/netobserv
9+
IMAGE: netobserv-agent
10+
IMAGE_ORG: netobserv
11+
12+
jobs:
13+
push-pr-image:
14+
if: ${{ github.event.label.name == 'ok-to-test' }}
15+
name: push PR image
16+
runs-on: ubuntu-20.04
17+
strategy:
18+
matrix:
19+
go: ['1.17']
20+
steps:
21+
- name: install make
22+
run: sudo apt-get install make
23+
- name: set up go 1.x
24+
uses: actions/setup-go@v2
25+
with:
26+
go-version: ${{ matrix.go }}
27+
- name: checkout
28+
uses: actions/checkout@v2
29+
with:
30+
ref: "refs/pull/${{ github.event.number }}/merge"
31+
- name: build images
32+
run: SW_VERSION=temp make ci-images-build
33+
- name: podman login to quay.io
34+
uses: redhat-actions/podman-login@v1
35+
with:
36+
username: ${{ env.REGISTRY_USER }}
37+
password: ${{ secrets.QUAY_SECRET }}
38+
registry: quay.io
39+
- name: get short sha
40+
id: shortsha
41+
run: echo "::set-output name=short_sha::$(git rev-parse --short HEAD)"
42+
- name: push to quay.io
43+
id: push-to-quay
44+
uses: redhat-actions/push-to-registry@v2
45+
with:
46+
image: ${{ env.IMAGE }}
47+
tags: ${{ steps.shortsha.outputs.short_sha }}
48+
registry: ${{ env.REGISTRY }}
49+
- uses: actions/github-script@v5
50+
with:
51+
github-token: ${{secrets.GITHUB_TOKEN}}
52+
script: |
53+
github.rest.issues.createComment({
54+
issue_number: context.issue.number,
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
body: 'New image: ${{ steps.push-to-quay.outputs.registry-paths }}. It will expire after two weeks.'
58+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Remove ok-to-test
2+
on:
3+
pull_request_target:
4+
types: [synchronize,reopened]
5+
6+
jobs:
7+
rm-ok-to-test:
8+
if: contains(github.event.pull_request.labels.*.name, 'ok-to-test')
9+
runs-on: ubuntu-20.04
10+
name: Remove ok-to-test
11+
steps:
12+
- uses: actions-ecosystem/action-remove-labels@v1
13+
with:
14+
labels: ok-to-test
15+
fail_on_error: true

0 commit comments

Comments
 (0)