-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (125 loc) · 4.91 KB
/
netbox.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Netbox
run-name: Netbox
permissions:
id-token: write
contents: read
actions: read
on:
push:
branches:
- "main"
paths:
- apps/netbox/netbox/ptlsbox/netbox.yaml
- DeleteAfterTesting
workflow_dispatch:
jobs:
netbox:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
# - name: Set up kubelogin for non-interactive login
# uses: azure/use-kubelogin@v1
# with:
# kubelogin-version: 'v0.0.24'
# - name: Azure Login
# uses: azure/login@v1
# with:
# client-id: ae4401e2-f8e6-4bbd-9ced-f42c4dfaea70
# tenant-id: 531ff96d-0ae9-462a-8d2d-bec7c0b42082
# allow-no-subscriptions: true
# - uses: azure/aks-set-context@v3
# name: Get Aks context
# with:
# resource-group: 'ss-ptlsbox-00-rg'
# cluster-name: 'ss-ptlsbox-00-aks'
# subscription: DTS-SHAREDSERVICESPTL-SBOX
# admin: true
# - name: install testkube
# run: wget -qO - https://repo.testkube.io/key.pub | sudo apt-key add - && echo "deb https://repo.testkube.io/linux linux main" | sudo tee -a /etc/apt/sources.list && sudo apt-get update && sudo apt-get install -y testkube
# - name: delete netbox test resource
# run: |
# #!/usr/bin/env bash
# if [[ $(testkube get test curl-test --no-execution) ]]; then
# testkube delete test curl-test
# fi
# - name: Create a test resource for netbox
# run: testkube create test --file pipeline-testkube/testkube-netbox.json --name netbox --type "curl/test"
# - name: Run test
# run: testkube run test netbox
# - name: sleep
# run: sleep 10
# - name: Get status
# run: echo "status=$(testkube get execution --test netbox -o json --limit 1 | jq -r '.results[].status')" >> $GITHUB_ENV
# - name: delete netbox test resource
# run: testkube delete test netbox
- run: echo $GITHUB_SHA
- name: Set env
run: echo "GH_SHA=$(echo $GITHUB_SHA)" >> $GITHUB_ENV
- run: echo ${{ env.GH_SHA }}
- name: get PR number
#if: "contains(env.status, 'passed')"
uses: octokit/[email protected]
id: get_pr_number
with:
route: GET /repos/mokainos/actions/commits/${{ env.GH_SHA }}/pulls
owner: octokit
repo: request-action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install jq tool
run: |
sudo apt-get update
sudo apt-get install jq
# - name: Set env
# if: "contains(env.status, 'passed')"
# run: |
# echo PR_TITLE=$(echo '${{ steps.get_pr_number.outputs.data }}' | jq -r '.[].title' ) >> $GITHUB_ENV
- name: Set env
run: |
echo PR_NUM=$(echo '${{ steps.get_pr_number.outputs.data }}' | jq -r '.[].number' ) >> $GITHUB_ENV
- run: echo ${{ env.PR_NUM }}
# - name: label open PRs
# if: contains(env.status, 'passed')
# run: |
# #!/usr/bin/env bash
# for pr in $(gh search prs --match title --repo hmcts/sds-flux-config --state open --json number,title --jq '.[] | select(.title | contains("${{ env.PR_TITLE }}"))| .number')
# do
# gh pr edit $pr --add-label "ApplicationTestPassed" --repo hmcts/sds-flux-config
# echo "updated PR $pr with the label"
# done
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: slack_msg_format_testing
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_ICON: ':smiley:'
SLACK_MESSAGE: '${{ env.PR_TITLE }}'
SLACK_TITLE: upgrade was successful
SLACK_USERNAME: netbox
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: revert PR
if: "!contains(env.status, 'passed')"
run: |
git config --global user.email "<>"
git config --global user.name "GitHub Actions Bot"
git status
git log -n 5
git pull
git status
git log -n 5
git revert -m 1 ${{ env.GH_SHA }} --no-edit
git checkout -b revert-commit-${{ env.PR_NUM }}
git status
git log -n 5
git push --set-upstream origin revert-commit-${{ env.PR_NUM }}
#git add .
#git commit -m "Reverting pull request #${{ env.PR_NUM }}"
gh pr create -f -t "Revert PR#${{ env.PR_NUM }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}