-
Notifications
You must be signed in to change notification settings - Fork 46
89 lines (72 loc) · 3.85 KB
/
publish.yml
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
name: Publish Images
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches:
- master
- 'release-*.*.*'
- 'sprint-*'
tags:
- 'release-*.*.*'
workflow_dispatch:
env:
SUPPORTED_CHANNELS: release-v1.3,release-v1.4,release-v1.5,release-v1.6,release-v1.7
REGISTRY: quay.io
IMAGE_NAME: ${{ github.repository }}
BUNDLE_SUFFIX: bundle
CONTAINER_SUFFIX: container
INDEX_SUFFIX: index
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get opm
run: wget $(curl -s https://api.github.com/repos/operator-framework/operator-registry/releases/latest | grep 'browser_' | cut -d\" -f4 | grep linux) -O opm && chmod +x opm
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Build container image
run: docker build . --file build/Dockerfile --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.CONTAINER_SUFFIX }}:${{ steps.extract_branch.outputs.branch }}
- name: Build bundle image
run: docker build . --file build/Dockerfile.${{ env.BUNDLE_SUFFIX }} --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:${{ steps.extract_branch.outputs.branch }}
- name: Log into registry
run: echo "${{ secrets.QUAY_PUBLISH_TOKEN }}" | docker login quay.io -u ${{ secrets.QUAY_PUBLISH_ROBOT }} --password-stdin
- name: Push container image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.CONTAINER_SUFFIX }}:${{ steps.extract_branch.outputs.branch }}
- name: Push bundle image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:${{ steps.extract_branch.outputs.branch }}
- name: Retag container image
run: docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.CONTAINER_SUFFIX }}:${{ steps.extract_branch.outputs.branch }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.CONTAINER_SUFFIX }}:latest
if: ${{ github.ref == 'refs/heads/master' }}
- name: Retag bundle image
run: docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:${{ steps.extract_branch.outputs.branch }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:latest
if: ${{ github.ref == 'refs/heads/master' }}
- name: push retagged container image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.CONTAINER_SUFFIX }}:latest
if: ${{ github.ref == 'refs/heads/master' }}
- name: push retagged bundle image
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:latest
if: ${{ github.ref == 'refs/heads/master' }}
- name: Get latest bundle images
run: |
git fetch -q origin
BUNDLES=""
for i in $(echo $SUPPORTED_CHANNELS | sed "s/,/ /g"); do
BUNDLES=$(echo $BUNDLES,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:$(git branch -r --contains $i | tail -n 1 | grep release | cut -d '/' -f 2 ) | sed 's/^,//')
done
BUNDLES=$BUNDLES,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.BUNDLE_SUFFIX }}:latest
echo "##[set-output name=bundles]$(echo $BUNDLES)"
id: get_bundles
- name: Run OPM
run: ./opm index add -c docker --bundles ${{ steps.get_bundles.outputs.bundles }} --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.INDEX_SUFFIX }}:latest
- name: Push index
run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ env.INDEX_SUFFIX }}:latest