-
Notifications
You must be signed in to change notification settings - Fork 20
116 lines (100 loc) · 3.95 KB
/
m2k-func.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
name: Build and push move2kube Knative function container image
on:
workflow_call:
inputs:
it_mode:
required: false
type: boolean
default: false
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- 'move2kube/m2k-func/**'
- 'pipeline/**'
- .github/workflows/m2k-func.yaml
env:
WORKDIR: move2kube/m2k-func
MVN_OPTS: ""
WF_CONFIG_REPO: parodos-dev/serverless-workflows-config
REGISTRY_REPO: orchestrator
GH_TOKEN: ${{ secrets.HELM_REPO_TOKEN }}
jobs:
build-and-push-m2k-func:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Buildah Action
id: build-image
uses: redhat-actions/buildah-build@v2
with:
context: ${{ env.WORKDIR }}
image: serverless-workflow-m2k-kfunc
tags: latest ${{ github.sha }}
extra-args: --ulimit nofile=4096:4096
containerfiles: |
${{ env.WORKDIR }}/src/main/docker/Dockerfile.jvm
- name: Buildah push to OCI Arcive
if: ${{ inputs.it_mode }}
run: |
buildah push serverless-workflow-m2k-kfunc:${{ github.sha }} \
oci-archive:serverless-workflow-m2k-kfunc-${{ github.sha }}.tar:kind.local/orchestrator/serverless-workflow-m2k-kfunc:${{ github.sha }}
- name: Save OCI archive
if: ${{ inputs.it_mode }}
uses: actions/upload-artifact@v4
with:
name: serverless-workflow-m2k-kfunc-${{ github.sha }}.tar
path: serverless-workflow-m2k-kfunc-${{ github.sha }}.tar
- name: Push To quay.io
if: ${{ ! inputs.it_mode }}
id: push-to-quay
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: quay.io/orchestrator
username: ${{ secrets.NEW_QUAY_USERNAME }}
password: ${{ secrets.NEW_QUAY_PASSWORD }}
- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
- uses: actions/github-script@v7
id: get_pr_data
with:
script: |
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
- name: Send PRs to config repo
if: ${{ ! inputs.it_mode }}
run: |
git config --global user.email "${{ github.event.head_commit.author.email || '[email protected]' }}"
git config --global user.name ${{ github.event.head_commit.author.name || github.triggering_actor }}
gh repo clone $WF_CONFIG_REPO config-repo
cd config-repo
git switch -c m2k-kfunc-autopr-$RANDOM
./hack/bump_chart_version.sh move2kube --bump-patch-version
yq --inplace '.kfunction.image="quay.io/orchestrator/serverless-workflow-m2k-kfunc:${{ github.sha }}"' charts/move2kube/values.yaml
git add -A
# determine pr or commit url
if [ ${{ fromJSON(steps.get_pr_data.outputs.result)}} != "" ]; then
PR_OR_COMMIT_URL="${{ fromJSON(steps.get_pr_data.outputs.result).html_url }}"
else
PR_OR_COMMIT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
fi
git commit -m "(m2k-kfunc) Automated PR for m2k-kfunc"
echo "Automated PR from $PR_OR_COMMIT_URL" | git commit --amend --file=-
git remote set-url origin https://${{ env.GH_TOKEN }}@github.com/$WF_CONFIG_REPO
git push origin HEAD
gh pr create -f --title "m2k-kfunc: Automatic m2k-kfunc image tag bump" \
--body "
Updating generated image tag for m2k-kfunc application
This PR was created automatically as a result of merging $PR_OR_COMMIT_URL
"