diff --git a/.tekton/operator-index-ocp-v4-19-build.yaml b/.tekton/operator-index-ocp-v4-19-build.yaml index 164be7b..17089c3 100644 --- a/.tekton/operator-index-ocp-v4-19-build.yaml +++ b/.tekton/operator-index-ocp-v4-19-build.yaml @@ -40,6 +40,9 @@ spec: - name: git-auth secret: secretName: '{{ git_auth_secret }}' + - name: github-auth + secret: + secretName: rhacs-github-bot-token pipelineRef: name: operator-index-pipeline diff --git a/.tekton/operator-index-pipeline.yaml b/.tekton/operator-index-pipeline.yaml index e93e13b..43ed196 100644 --- a/.tekton/operator-index-pipeline.yaml +++ b/.tekton/operator-index-pipeline.yaml @@ -280,7 +280,26 @@ spec: when: - input: $(tasks.init.results.build) operator: in - values: ["true"] + values: [ "true" ] + + - name: post-pr-comment-fbc-build + params: + - name: REPO + value: stackrox/operator-index + - name: PR_NUMBER + value: $(context.pipelineRun.annotations['build.appstudio.redhat.com/pull_request_number']) + - name: IMAGE_URL + value: $(tasks.build-image-index.results.IMAGE_URL) + workspaces: + - name: github-auth + workspace: git-auth + taskRef: + name: post-pr-comment-fbc-build + when: + - input: $(params.skip-checks) + operator: in + values: [ "false" ] + - name: deprecated-base-image-check params: - name: IMAGE_URL diff --git a/.tekton/post-pr-comment-fbc-build.yaml b/.tekton/post-pr-comment-fbc-build.yaml new file mode 100644 index 0000000..a6ccca9 --- /dev/null +++ b/.tekton/post-pr-comment-fbc-build.yaml @@ -0,0 +1,42 @@ +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: post-pr-comment-fbc-build +spec: + params: + - name: REPO + type: string + description: GitHub repo in 'owner/repo' format + - name: PR_NUMBER + type: string + description: PR number to post to + - name: IMAGE_URL + type: string + description: FBC build image URL to post as a comment + workspaces: + - name: github-auth + description: Workspace with the GitHub token secret + steps: + - name: show-fbc-build-images + image: registry.redhat.io/rhel9/python-311@sha256:47e23afaf5daf6a98e76a3b5a924b85bbcb19c72b5c6ac474a418aea54cd8aae + env: + - name: GITHUB_TOKEN + value: "$(params.github_token)" + script: | + #!/usr/bin/env python3 + import os + import requests + + pr_number = os.environ["PR_NUMBER"] + image_url = os.environ["IMAGE_URL"] + token = os.environ["GITHUB_TOKEN"] + + url = f"https://api.github.com/repos/stackrox/operator-index/issues/{pr_number}/comments" + headers = { + "Authorization": f"token {token}", + "Accept": "application/vnd.github.v3+json" + } + data = {"body": f"Build image URL: {image_url}"} + resp = requests.post(url, headers=headers, json=data) + print("Status:", resp.status_code) + print("Response:", resp.text) \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1b76004 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "cSpell.words": [ + "goccy", + "mediatype", + "rhacs" + ] +} \ No newline at end of file