forked from nautobot/go-nautobot
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (73 loc) · 2.77 KB
/
release.yml
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
---
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
name: "Release a new go-nautobot version"
on:
workflow_dispatch:
inputs:
tag:
description: "Tag version to release"
type: string
required: true
jobs:
release-go-nautobot:
runs-on: "ubuntu-20.04"
env:
NAUTOBOT_VER: "${{ github.event.inputs.tag }}"
PYTHON_VER: "3.9"
steps:
- name: "Get go-nautobot generator code"
uses: actions/checkout@v3
- name: "Set up Docker Compose"
run: |
curl -L "https://github.com/docker/compose/releases/download/v2.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- name: "Start Nautobot and Generator"
run: |
cd development
docker-compose --project-name go_nautobot -f docker-compose.yml up --build --abort-on-container-exit
- name: "Commit Changes"
run: |
TAG=v$( cat api/nautobot_version )
git config --global user.name 'GitHub CI'
git config --global user.email '[email protected]'
git add -A
git remote set-url origin https://${{ secrets.BOT_GITHUB_USERNAME }}:${{ secrets.BOT_GITHUB_TOKEN }}@github.com/${{ github.repository }}
git checkout
git commit -am "Release $TAG"
git tag "$TAG"
git push
git push --tags
slack-notify:
needs:
- "release-go-nautobot"
runs-on: "ubuntu-20.04"
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_MESSAGE: >-
*NOTIFICATION: NEW-RELEASE-PUBLISHED*\n
Repository: <${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>\n
Release: <${{ github.server_url }}/${{ github.repository }}/releases/tag/v${{ github.event.inputs.tag }}}|v${{ github.event.inputs.tag }}>\n
Published by: <${{ github.server_url }}/${{ github.actor }}|${{ github.actor }}>
steps:
- name: "Send a notification to Slack"
# ENVs cannot be used directly in job.if. This is a workaround to check
# if SLACK_WEBHOOK_URL is present.
if: "${{ env.SLACK_WEBHOOK_URL != '' }}"
uses: "slackapi/[email protected]"
with:
payload: |
{
"text": "${{ env.SLACK_MESSAGE }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ env.SLACK_MESSAGE }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK_URL }}"
SLACK_WEBHOOK_TYPE: "INCOMING_WEBHOOK"