Skip to content

Commit 6fc2303

Browse files
authored
Merge pull request opendatahub-io#243 from HumairAK/fix_actions
Fix actions
2 parents fe8a539 + 810b718 commit 6fc2303

File tree

8 files changed

+158
-121
lines changed

8 files changed

+158
-121
lines changed

.github/actions/build/action.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: "Set up KinD"
2-
description: "Step to start and configure KinD cluster"
1+
name: "Create a podman build"
2+
description: "This workflow can be used to create a podman build and push to quay.io from source branches."
33
inputs:
44
IMAGE_REPO:
55
description: "Quay image repo name."
@@ -37,14 +37,14 @@ runs:
3737
# Case 4: >1 tags were created, but the most recent one was never deleted (same as case 3, but the latest tag does not have "end_ts".
3838
- name: Check if Image already exists
3939
shell: bash
40-
if: ${{ inputs.OVERWRITE }} == "false"
40+
if: inputs.OVERWRITE == 'false'
4141
env:
4242
IMAGE: quay.io/${{ env.QUAY_ORG }}/${{ inputs.IMAGE_REPO }}:${{ env.TARGET_IMAGE_TAG }}
4343
run: |
44+
echo ${{ inputs.OVERWRITE }}
45+
4446
tags=$(curl --request GET 'https://quay.io/api/v1/repository/${{ env.QUAY_ORG }}/${{ inputs.IMAGE_REPO }}/tag/?specificTag=${{ env.TARGET_IMAGE_TAG }}')
45-
echo $tags | yq .tags - | yq 'sort_by(.start_ts) | reverse' - -P | yq .[0].end_ts -
4647
latest_tag_has_end_ts=$(echo $tags | yq .tags - | yq 'sort_by(.start_ts) | reverse' - -P | yq .[0].end_ts -)
47-
echo $latest_tag_has_end_ts
4848
notempty=$(echo ${tags} | yq .tags - | yq any)
4949
5050
# Image only exists if there is a tag that does not have "end_ts" (i.e. it is still present).

.github/workflows/build-main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build images for Main branch
2+
on:
3+
push:
4+
branches:
5+
- main
6+
concurrency:
7+
group: ${{ github.workflow }}
8+
cancel-in-progress: true
9+
env:
10+
IMAGE_REPO_DSPO: data-science-pipelines-operator
11+
QUAY_ORG: opendatahub
12+
QUAY_ID: ${{ secrets.QUAY_ID }}
13+
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
14+
SOURCE_BRANCH: main
15+
jobs:
16+
build-image:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Generate Tag
21+
shell: bash
22+
id: tags
23+
run: |
24+
commit_sha=${{ github.event.after }}
25+
tag=main-${commit_sha:0:7}
26+
echo "tag=${tag}" >> $GITHUB_OUTPUT
27+
- name: Build Image
28+
uses: ./.github/actions/build
29+
env:
30+
IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}:${{ steps.tags.outputs.tag }}
31+
TARGET_IMAGE_TAG: ${{ steps.tags.outputs.tag }}
32+
with:
33+
OVERWRITE: true
34+
IMAGE_REPO: ${{ env.IMAGE_REPO_DSPO }}
35+
DOCKERFILE: Dockerfile
36+
GH_REPO: ${{ github.repository }}
37+
- name: Tag latest
38+
shell: bash
39+
env:
40+
IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}
41+
NEWEST_TAG: ${{ steps.tags.outputs.tag }}
42+
run: |
43+
podman tag ${IMG}:${NEWEST_TAG} ${IMG}:latest
44+
podman push ${IMG}:latest
45+
podman tag ${IMG}:${NEWEST_TAG} ${IMG}:main
46+
podman push ${IMG}:main

.github/workflows/build-prs.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build images for PRs
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- closed
8+
- synchronize
9+
permissions:
10+
pull-requests: read
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
env:
15+
IMAGE_REPO_DSPO: data-science-pipelines-operator
16+
SOURCE_BRANCH: ${{ github.event.pull_request.head.sha }}
17+
QUAY_ORG: opendatahub
18+
QUAY_ID: ${{ secrets.QUAY_ID }}
19+
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
20+
TARGET_IMAGE_TAG: pr-${{ github.event.pull_request.number }}
21+
GH_USER_EMAIL: [email protected]
22+
GH_USER_NAME: dsp-developers
23+
jobs:
24+
build-pr-image:
25+
if: github.event.pull_request.state == 'open'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- name: Build Image
30+
uses: ./.github/actions/build
31+
with:
32+
OVERWRITE: true
33+
IMAGE_REPO: ${{ env.IMAGE_REPO_DSPO }}
34+
DOCKERFILE: Dockerfile
35+
GH_REPO: ${{ github.repository }}
36+
- name: Send comment
37+
shell: bash
38+
env:
39+
GH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
40+
IMG: quay.io/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}:${{ env.TARGET_IMAGE_TAG }}
41+
run: |
42+
git config user.email "${{ env.GH_USER_EMAIL }}"
43+
git config user.name "${{ env.GH_USER_NAME }}"
44+
45+
action=${{ github.event.action }}
46+
47+
if [[ "$action" == "synchronize" ]]; then
48+
echo "Change to PR detected. A new PR build was completed." >> /tmp/body-file.txt
49+
fi
50+
51+
if [[ "$action" == "reopened" ]]; then
52+
echo "PR was re-opened." >> /tmp/body-file.txt
53+
fi
54+
55+
cat <<"EOF" >> /tmp/body-file.txt
56+
A new image has been built to help with testing out this PR: `${{ env.IMG }}`
57+
EOF
58+
59+
if [[ "$action" == "opened" || "$action" == "reopened" ]]; then
60+
cat <<"EOF" >> /tmp/body-file.txt
61+
An OCP cluster where you are logged in as cluster admin is required.
62+
63+
To use this image run the following:
64+
65+
```bash
66+
cd $(mktemp -d)
67+
git clone [email protected]:opendatahub-io/data-science-pipelines-operator.git
68+
cd data-science-pipelines-operator/
69+
git fetch origin pull/${{ github.event.pull_request.number }}/head
70+
git checkout -b pullrequest ${{ env.SOURCE_BRANCH }}
71+
make deploy IMG="${{ env.IMG }}"
72+
```
73+
74+
More instructions [here](https://github.com/opendatahub-io/data-science-pipelines-operator#deploy-dsp-instance) on how to deploy and test a Data Science Pipelines Application.
75+
76+
EOF
77+
fi
78+
79+
gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/body-file.txt
80+
81+
clean-pr-images:
82+
if: github.event.pull_request.state == 'closed'
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Delete PR image
86+
shell: bash
87+
run: |
88+
tag=$(curl --request GET 'https://quay.io/api/v1/repository/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}/tag/?specificTag=${{ env.TARGET_IMAGE_TAG }}')
89+
exists=$(echo ${tag} | yq .tags - | yq any)
90+
IMAGE=quay.io/${{ env.QUAY_ORG }}/${{ env.IMAGE_REPO_DSPO }}:${{ env.TARGET_IMAGE_TAG }}
91+
if [[ "$exists" == "true" ]]; then
92+
echo "PR Closed deleting image...${{ env.IMAGE }}."
93+
skopeo delete --creds ${{ env.QUAY_ID }}:${{ env.QUAY_TOKEN }} docker://${IMAGE}
94+
else
95+
echo "Deletion of image ${IMAGE} skipped because image already does not exist."
96+
fi

.github/workflows/tag-and-build.yml renamed to .github/workflows/build-tags.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v3
4646
- uses: ./.github/actions/build
47+
name: Build Image
4748
with:
4849
IMAGE_REPO: ${{ env.IMAGE_REPO_DSPO }}
4950
DOCKERFILE: Dockerfile
@@ -56,6 +57,7 @@ jobs:
5657
steps:
5758
- uses: actions/checkout@v3
5859
- uses: ./.github/actions/build
60+
name: Build Image
5961
with:
6062
IMAGE_REPO: ${{ env.IMAGE_REPO_SERVER }}
6163
DOCKERFILE: backend/Dockerfile
@@ -68,6 +70,7 @@ jobs:
6870
steps:
6971
- uses: actions/checkout@v3
7072
- uses: ./.github/actions/build
73+
name: Build Image
7174
with:
7275
IMAGE_REPO: ${{ env.IMAGE_REPO_UI }}
7376
DOCKERFILE: frontend/Dockerfile
@@ -80,6 +83,7 @@ jobs:
8083
steps:
8184
- uses: actions/checkout@v3
8285
- uses: ./.github/actions/build
86+
name: Build Image
8387
with:
8488
IMAGE_REPO: ${{ env.IMAGE_REPO_CACHE }}
8589
DOCKERFILE: backend/Dockerfile.cacheserver
@@ -92,6 +96,7 @@ jobs:
9296
steps:
9397
- uses: actions/checkout@v3
9498
- uses: ./.github/actions/build
99+
name: Build Image
95100
with:
96101
IMAGE_REPO: ${{ env.IMAGE_REPO_PA }}
97102
DOCKERFILE: backend/Dockerfile.persistenceagent
@@ -104,6 +109,7 @@ jobs:
104109
steps:
105110
- uses: actions/checkout@v3
106111
- uses: ./.github/actions/build
112+
name: Build Image
107113
with:
108114
IMAGE_REPO: ${{ env.IMAGE_REPO_SWF }}
109115
DOCKERFILE: backend/Dockerfile.scheduledworkflow
@@ -116,6 +122,7 @@ jobs:
116122
steps:
117123
- uses: actions/checkout@v3
118124
- uses: ./.github/actions/build
125+
name: Build Image
119126
with:
120127
IMAGE_REPO: ${{ env.IMAGE_REPO_VC }}
121128
DOCKERFILE: backend/Dockerfile.viewercontroller
@@ -128,6 +135,7 @@ jobs:
128135
steps:
129136
- uses: actions/checkout@v3
130137
- uses: ./.github/actions/build
138+
name: Build Image
131139
with:
132140
IMAGE_REPO: ${{ env.IMAGE_REPO_ARTIFACT }}
133141
DOCKERFILE: backend/artifact_manager/Dockerfile
@@ -140,6 +148,7 @@ jobs:
140148
steps:
141149
- uses: actions/checkout@v3
142150
- uses: ./.github/actions/build
151+
name: Build Image
143152
with:
144153
IMAGE_REPO: ${{ env.IMAGE_REPO_MLMD_WRITER }}
145154
DOCKERFILE: backend/metadata_writer/Dockerfile
@@ -152,6 +161,7 @@ jobs:
152161
steps:
153162
- uses: actions/checkout@v3
154163
- uses: ./.github/actions/build
164+
name: Build Image
155165
with:
156166
IMAGE_REPO: ${{ env.IMAGE_REPO_MLMD_ENVOY }}
157167
DOCKERFILE: third-party/metadata_envoy/Dockerfile
@@ -164,6 +174,7 @@ jobs:
164174
steps:
165175
- uses: actions/checkout@v3
166176
- uses: ./.github/actions/build
177+
name: Build Image
167178
with:
168179
IMAGE_REPO: ${{ env.IMAGE_REPO_MLMD_GRPC }}
169180
DOCKERFILE: third-party/ml-metadata/Dockerfile

.github/workflows/image-check.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
name: Image-check
22
on:
3-
push:
4-
branches:
5-
- '**'
6-
tags-ignore:
7-
- 'v*'
83
pull_request:
9-
workflow_dispatch:
10-
114
jobs:
125
test:
136
runs-on: ubuntu-latest

.github/workflows/pr-merged-image-delete.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/precommit.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
name: Pre-commit
22
on:
3-
push:
4-
branches:
5-
- '**'
6-
tags-ignore:
7-
- 'v*'
83
pull_request:
9-
workflow_dispatch:
10-
114
jobs:
125
precommit:
136
runs-on: ubuntu-latest
@@ -22,12 +15,10 @@ jobs:
2215
- /cache
2316
steps:
2417
- uses: actions/checkout@v2
25-
2618
- name: Activate cache
2719
uses: actions/cache@v2
2820
with:
2921
path: /cache
3022
key: ${{ runner.os }}-cache-${{ hashFiles('**/go.sum', '.pre-commit-config.yaml') }}
31-
3223
- name: Run pre-commit checks
3324
run: pre-commit run --all-files

0 commit comments

Comments
 (0)