-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #168 from sosiouxme/20241118-TRT-1107-github-app
TRT-1107: GitHub app auth for cronjob
- Loading branch information
Showing
3 changed files
with
67 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
FROM registry.access.redhat.com/ubi9/ubi:latest AS builder | ||
WORKDIR /go/src/openshift-eng/ci-test-mapping | ||
COPY . . | ||
ENV PATH="/go/bin:${PATH}" | ||
ENV GOPATH="/go" | ||
RUN dnf install -y \ | ||
git \ | ||
go \ | ||
make && make build | ||
|
||
FROM gcr.io/k8s-prow/pr-creator:latest AS prcreator | ||
make \ | ||
&& go install github.com/Link-/gh-token@latest \ | ||
k8s.io/test-infra/robots/pr-creator@latest | ||
COPY . . | ||
RUN make build | ||
|
||
FROM registry.access.redhat.com/ubi9/ubi:latest AS base | ||
RUN dnf install -y git jq | ||
COPY --from=builder /go/src/openshift-eng/ci-test-mapping/ci-test-mapping /bin/ci-test-mapping | ||
COPY --from=prcreator /ko-app/pr-creator /bin/pr-creator | ||
RUN dnf install -y git | ||
COPY --from=builder /go/bin/gh-token /bin/gh-token | ||
COPY --from=builder /go/bin/pr-creator /bin/pr-creator | ||
COPY hack /hack | ||
ENTRYPOINT ["/bin/ci-test-mapping"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
set -x | ||
export HOME=/tmp | ||
# Prune older records first, we can't prune after we write | ||
# to the table with records in the streaming buffer | ||
ci-test-mapping prune | ||
|
||
set -o errexit | ||
set -o pipefail | ||
|
||
# Clone the repo | ||
cd /tmp | ||
git clone https://github.com/openshift-eng/ci-test-mapping.git | ||
cd ci-test-mapping | ||
git checkout -b update | ||
|
||
# Generate and push mapping | ||
## OCP Engineering Mappings | ||
ci-test-mapping map --mode=bigquery --push-to-bigquery | ||
## QE Mappings | ||
ci-test-mapping map --mode=bigquery --push-to-bigquery \ | ||
--bigquery-dataset ci_analysis_qe --bigquery-project openshift-gce-devel \ | ||
--table-junit junit --table-mapping component_mapping --config "" | ||
|
||
if git diff --quiet | ||
then | ||
echo "No changes." | ||
exit 0 | ||
fi | ||
|
||
# get token with write ability (after querying DB; do not give the token a chance to expire) | ||
keyfile="${GHAPP_KEYFILE:-/secrets/ghapp/private.key}" | ||
set +x | ||
trt_token=`gh-token generate --app-id 1046118 --key "$keyfile" --installation-id 57361690 --token-only` # 57361690 = openshift-trt | ||
git remote add openshift-trt "https://oauth2:${trt_token}@github.com/openshift-trt/ci-test-mapping.git" | ||
set -x | ||
git commit -a -m "Update test mapping" | ||
git push openshift-trt update --force | ||
|
||
pr-creator -github-app-private-key-path "${keyfile}" -github-app-id 1046118 \ | ||
-org openshift-eng -repo ci-test-mapping \ | ||
-source openshift-trt:update -branch main \ | ||
-body "Automatically generated component mapping update" \ | ||
-title "Update component readiness test mapping" \ | ||
-confirm |