github.com/instana/go-sensor@v1.62.2-0.20240520081010-4919868049e1/.tekton/tracer-reports/task.yaml (about) 1 # (c) Copyright IBM Corp. 2024 2 3 --- 4 apiVersion: tekton.dev/v1 5 kind: Task 6 metadata: 7 name: repos-clone-task 8 spec: 9 workspaces: 10 - name: task-pvc 11 mountPath: /workspace 12 steps: 13 - name: clone-go-sensor-repo 14 image: alpine/git:2.43.0 15 workingDir: /workspace/ 16 script: | 17 #!/bin/sh 18 echo "Cloning repo!" 19 git clone --depth 1 -b main https://github.com/instana/go-sensor && cd /workspace/go-sensor && git status 20 - name: clone-tracer-reports 21 image: alpine/git:2.43.0 22 env: 23 - name: GITHUB_ENTERPRISE_TOKEN 24 valueFrom: 25 secretKeyRef: 26 name: "github-enterprise-token" 27 key: "token" 28 - name: REPO_URL 29 valueFrom: 30 secretKeyRef: 31 name: "tracer-reports-repo-url" 32 key: "url" 33 workingDir: /workspace/ 34 script: | 35 #!/bin/sh 36 echo "Cloning repo!" 37 git clone --depth 1 -b main https://oauth2:$GITHUB_ENTERPRISE_TOKEN@$REPO_URL && cd /workspace/tracer-reports && git status 38 39 --- 40 apiVersion: tekton.dev/v1 41 kind: Task 42 metadata: 43 name: script-run-task 44 spec: 45 workspaces: 46 - name: task-pvc 47 mountPath: /workspace 48 steps: 49 - name: run-tracer-reports-script 50 image: golang:1.22.0 51 workingDir: /workspace/ 52 script: | 53 cd /workspace/go-sensor 54 bash currency_report.sh 55 56 --- 57 apiVersion: tekton.dev/v1 58 kind: Task 59 metadata: 60 name: git-push-task 61 spec: 62 workspaces: 63 - name: task-pvc 64 mountPath: /workspace 65 steps: 66 - name: push-tracer-reports 67 image: alpine/git:2.43.0 68 env: 69 - name: GITHUB_ENTERPRISE_USER_EMAIL 70 valueFrom: 71 secretKeyRef: 72 name: "github-enterprise-user-email" 73 key: "email" 74 workingDir: /workspace/tracer-reports/ 75 script: | 76 git config user.name "IBM/Instana/Team Go" 77 git config user.email "$GITHUB_ENTERPRISE_USER_EMAIL" 78 git add automated/currency/go/report.md || true 79 git commit -m "Updated tracer reports for Team Go : $(date +'%d-%b-%Y %H:%M:%S')" || true 80 git push origin @ || true 81 82 83 --- 84 apiVersion: tekton.dev/v1 85 kind: Task 86 metadata: 87 name: notify-slack-task 88 spec: 89 params: 90 - name: STATE 91 workspaces: 92 - name: task-pvc 93 mountPath: /workspace 94 steps: 95 - name: slack-notification 96 image: curlimages/curl:8.7.1 97 env: 98 - name: STATE 99 value: $(params.STATE) 100 - name: SLACK_TOKEN 101 valueFrom: 102 secretKeyRef: 103 name: "slack-token" 104 key: "token" 105 - name: SLACK_CHANNEL_ID 106 valueFrom: 107 secretKeyRef: 108 name: "slack-channel-id" 109 key: "id" 110 workingDir: /workspace/go-sensor/ 111 script: | 112 #!/bin/sh 113 114 if [ "$STATE" = "Failed" ] || [ "$STATE" = "None" ]; then 115 message=":alert-8281: Go Tracer - Currency reports generation failed :alert-blue:" 116 else 117 if [ -s output.txt ]; then 118 content=$(cat output.txt) 119 message=":mega: Go Tracer - Currency reports generated successfully :mega: \`\`\`$content\`\`\`" 120 else 121 message=":mega: Go Tracer - Currency reports generated successfully :mega:" 122 fi 123 fi 124 125 curl -d "text=$message" -d "channel=$SLACK_CHANNEL_ID" -H "Authorization: Bearer $SLACK_TOKEN" -X POST https://slack.com/api/chat.postMessage