forked from bcgov/NotifyBC
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add github workflow, pipeline, pipelinerun and tasks #34
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Build API Image. | ||
on: | ||
push: | ||
branches: | ||
- v5 | ||
paths: | ||
- 'src/**' | ||
workflow_dispatch: | ||
defaults: | ||
run: | ||
working-directory: ./ | ||
jobs: | ||
deploy_api_on_openshift: | ||
if: github.repository_owner == 'bcgov' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to OpenShift and open the correct namespace | ||
uses: redhat-developer/[email protected] | ||
with: | ||
version: 'latest' | ||
openshift_server_url: ${{ secrets.OpenShiftServerURL }} | ||
parameters: '{"apitoken": "${{ secrets.OpenShiftToken }}", "acceptUntrustedCerts": "true"}' | ||
cmd: | | ||
oc project ${{ secrets.OpenShiftNamespace }} | ||
|
||
- name: Create PipelineRun | ||
run: | | ||
oc create -f helm/deployments/openshift/tekton/build-pipelinerun.yaml |
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,34 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Pipeline | ||
metadata: | ||
name: build-pipeline | ||
spec: | ||
params: | ||
- description: The name of the secret holding the Rocket.Chat URL | ||
name: rocketchat-url-secret | ||
type: string | ||
tasks: | ||
- name: start-build | ||
taskRef: | ||
kind: Task | ||
name: start-build | ||
- name: send-to-rocketchat | ||
params: | ||
- name: url-secret | ||
value: $(params.rocketchat-url-secret) | ||
- name: options | ||
value: | ||
- '-X' | ||
- POST | ||
- '-H' | ||
- 'Content-Type: application/json' | ||
- '-v' | ||
- '--data' | ||
- >- | ||
{"alias": "DESCW OC Alerts", "text": | ||
"$(tasks.start-build.results.exit-status)"} | ||
runAfter: | ||
- start-build | ||
taskRef: | ||
kind: Task | ||
name: curl |
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,16 @@ | ||
# .github/pipelines/pipelinerun.yaml | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
generateName: build-pipelinerun- | ||
labels: | ||
tekton.dev/pipeline: build-pipeline | ||
spec: | ||
params: | ||
- name: rocketchat-url-secret | ||
value: rocketchat-url | ||
pipelineRef: | ||
name: build-pipeline | ||
serviceAccountName: pipeline | ||
timeouts: | ||
pipeline: 1h0m0s |
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,35 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: curl | ||
labels: | ||
app.kubernetes.io/version: '0.1' | ||
spec: | ||
description: This task performs curl operation to transfer data from internet. | ||
params: | ||
- description: Name of the secret which holds the URL to be curl'ed. | ||
name: url-secret | ||
type: string | ||
- description: Options for the url command. | ||
name: options | ||
type: array | ||
- default: >- | ||
docker.io/curlimages/curl:7.72.0@sha256:bd5bbd35f89b867c1dccbc84b8be52f3f74dea20b46c5fe0db3780e040afcb6f | ||
description: Image of curl to pull. | ||
name: curl-image | ||
type: string | ||
steps: | ||
- args: | ||
- '$(params.options[*])' | ||
- $(URL) | ||
command: | ||
- curl | ||
env: | ||
- name: URL | ||
valueFrom: | ||
secretKeyRef: | ||
key: url | ||
name: $(params.url-secret) | ||
image: $(params.curl-image) | ||
name: curl | ||
resources: {} |
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,27 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: start-build | ||
spec: | ||
results: | ||
- description: Output of the start-build command | ||
name: build-output | ||
type: string | ||
- description: Status of the build ("Build Succeeded" or "Build Failed") | ||
name: exit-status | ||
type: string | ||
steps: | ||
- image: 'quay.io/openshift/origin-cli:latest' | ||
name: start-build | ||
resources: {} | ||
script: | | ||
#!/bin/sh | ||
output=$(oc start-build notify-bc --wait) | ||
exit_code=$? | ||
echo "$output" > /tekton/results/build-output | ||
if [ "$exit_code" -eq 0 ]; then | ||
echo -n "Build Succeeded" > /tekton/results/exit-status | ||
else | ||
echo -n "Build Failed" > /tekton/results/exit-status | ||
fi | ||
exit 0 # Continue the pipeline even if the task fails |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a helm value? and if so i suspect there is a follow up pr for the tenant repo!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is the name of the openshift secret that the curl task (see that file below) will look up and use. It is provided by the pipeline-run (in this case "rocketchat-url").