Skip to content

Commit 7d94b3b

Browse files
authored
Merge pull request #19 from stakater/improve-workflows
Improve workflows
2 parents ba6a3ad + 34ea984 commit 7d94b3b

File tree

15 files changed

+299
-356
lines changed

15 files changed

+299
-356
lines changed

.github/actions/build/action.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: "Build & Push"
2+
description: "Build and push images"
3+
inputs:
4+
TAG:
5+
description: "The tag for the workflow run"
6+
required: true
7+
8+
IMAGE_REPOSITORY:
9+
description: "The tag for the workflow run"
10+
required: true
11+
12+
OPM_VERSION:
13+
description: OPM CLI version to use
14+
default: "v1.50.0"
15+
required: false
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Install CLI tools
20+
uses: redhat-actions/openshift-tools-installer@v1
21+
with:
22+
source: "github"
23+
opm: ${{ inputs.OPM_VERSION }}
24+
25+
- name: Build and Push Bundle
26+
run: make bundle bundle-build bundle-push
27+
shell: bash
28+
env:
29+
GIT_TAG: ${{ inputs.TAG }}
30+
31+
- name: Build and Push Catalog
32+
run: make catalog-render catalog-build catalog-push
33+
shell: bash
34+
env:
35+
GIT_TAG: ${{ inputs.TAG }}
36+
37+
- name: Check if changes are made to catalog
38+
uses: dorny/paths-filter@v3
39+
id: catalog_changed
40+
with:
41+
filters: |
42+
catalog:
43+
- "${{ inputs.CATALOG_DIR_PATH }}/**"
44+
45+
- name: Push Latest Tag
46+
if: ${{ steps.catalog_changed.outputs.catalog == 'true' }}
47+
uses: anothrNick/[email protected]
48+
env:
49+
GITHUB_TOKEN: ${{ env.ADMIN_TOKEN }}
50+
WITH_V: true
51+
RELEASE_BRANCHES: ${{ inputs.RELEASE_BRANCH }}
52+
DEFAULT_BUMP: patch

.github/actions/docker/action.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: "Setup Docker"
2+
description: "Setup Docker repository"
3+
inputs:
4+
TAG:
5+
description: Git action Tag
6+
required: true
7+
8+
outputs:
9+
IMAGE_REPOSITORY:
10+
description: "The tag for the workflow run"
11+
value: ${{ steps.repository.outputs.IMAGE_REPOSITORY }}
12+
runs:
13+
using: "composite"
14+
steps:
15+
- name: Verify container registry secrets
16+
shell: bash
17+
run: |
18+
if [ "$CONTAINER_REGISTRY_URL" == "" ] || [ "$CONTAINER_REGISTRY_USERNAME" == "" ] || [ "$CONTAINER_REGISTRY_PASSWORD" == "" ]; then
19+
echo "Required secrets 'CONTAINER_REGISTRY_URL' or 'CONTAINER_REGISTRY_USERNAME' or 'CONTAINER_REGISTRY_PASSWORD' are not set!"
20+
exit 1
21+
fi
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
with:
29+
driver-opts: image=moby/buildkit:v0.9.3
30+
buildkitd-flags: --debug
31+
32+
- name: Login to Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.CONTAINER_REGISTRY_URL }}
36+
username: ${{ env.CONTAINER_REGISTRY_USERNAME }}
37+
password: ${{ env.CONTAINER_REGISTRY_PASSWORD }}
38+
39+
- name: Generate image repository path
40+
id: repository
41+
shell: bash
42+
run: |
43+
echo IMAGE_REPOSITORY=$(echo $CONTAINER_REGISTRY_URL/${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]') | tee -a $GITHUB_OUTPUT $GITHUB_ENV

.github/actions/notify/action.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Notify"
2+
description: "Finalization notification"
3+
inputs:
4+
IMAGE_REPOSITORY:
5+
description: "The Docker image repository"
6+
required: true
7+
TAG:
8+
description: "The tag for the workflow run"
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Verify Slack secrets
14+
shell: bash
15+
run: |
16+
if [ "$SLACK_WEBHOOK_URL" == "" ]; then
17+
echo "Required Secret 'SLACK_WEBHOOK_URL' is not set!"
18+
exit 1
19+
fi
20+
21+
- name: Comment on PR
22+
uses: mshick/add-pr-comment@v2
23+
if: always()
24+
env:
25+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
26+
with:
27+
message-success: '@${{ github.actor }} Image is available for testing. `docker pull ${{ inputs.IMAGE_REPOSITORY }}:${{ inputs.TAG }}`'
28+
message-failure: '@${{ github.actor }} Yikes! You better fix it before anyone else finds out! [Build](https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}/checks) has Failed!'
29+
allow-repeats: true
30+
31+
- name: Notify Slack
32+
uses: 8398a7/action-slack@v3
33+
if: always()
34+
with:
35+
status: ${{ job.status }}
36+
fields: repo,author,action,eventName,ref,workflow
37+
env:
38+
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}

.github/actions/tag/action.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Generate Tag"
2+
description: "Setup Docker"
3+
inputs:
4+
RELEASE_BRANCH:
5+
description: Release branch to push changes
6+
required: false
7+
default: main
8+
outputs:
9+
TAG:
10+
description: "The tag for the workflow run"
11+
value: ${{ steps.tag.outputs.TAG }}
12+
13+
PR_TAG:
14+
description: "The PR tag for the workflow run"
15+
value: ${{ steps.tag.outputs.PR_TAG }}
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: Generate Tag
20+
id: generate
21+
uses: anothrNick/[email protected]
22+
env:
23+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
24+
WITH_V: false
25+
DEFAULT_BUMP: patch
26+
RELEASE_BRANCHES: ${{ inputs.RELEASE_BRANCH }}
27+
DRY_RUN: true
28+
29+
- name: Set Tag
30+
shell: bash
31+
run: echo "TAG=${{ steps.generate.outputs.new_tag }}" >> $GITHUB_ENV
32+
33+
- name: Set Tag
34+
id: tag
35+
shell: bash
36+
run: |
37+
sha=${{ github.event.pull_request.head.sha }}
38+
tag="-SNAPSHOT-PR-${{ github.event.pull_request.number }}-${sha:0:8}"
39+
echo "TAG=${{ steps.generate.outputs.new_tag }}" >> $GITHUB_OUTPUT
40+
echo "PR_TAG=$(echo ${tag})" >> $GITHUB_OUTPUT

.github/actions/verify/action.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Verify"
2+
description: "Verify code"
3+
inputs:
4+
ENABLE_LINTING:
5+
description: Run golangci-lint
6+
default: "true"
7+
required: false
8+
9+
ENABLE_UNIT_TESTS:
10+
description: Run golang tests
11+
default: "true"
12+
required: false
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Run lint
17+
if: ${{ inputs.ENABLE_LINTING == 'true' }}
18+
shell: bash
19+
run: make lint
20+
21+
- name: Run Tests
22+
if: ${{ inputs.ENABLE_UNIT_TESTS == 'true' }}
23+
shell: bash
24+
run: make test

0 commit comments

Comments
 (0)