-
Notifications
You must be signed in to change notification settings - Fork 93
110 lines (92 loc) · 3.93 KB
/
rasaoss-version-bumper.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
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
# Bump Rasa OSS version and prepare a PR for it
name: Bump Rasa OSS version
on:
schedule:
# Run once a day at 08:00
- cron: '0 8 * * *'
workflow_dispatch:
jobs:
bump_rasa_oss_version:
runs-on: ubuntu-latest
if: github.repository_owner == 'RasaHQ'
steps:
- name: Authenticate GitHub CLI
run: |
# https://cli.github.com/manual/gh_auth_login
# read token from standard input
gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }}
# Get latest Rasa OSS release version, exclude an alpha or dev tags
- name: Get the latest Rasa OSS version 🏷
run: |
LATEST_RASA_VERSION=$(gh release list --repo github.com/RasaHQ/rasa --limit 10 | awk '{print $1}' | sort -r -V | grep -E "^[0-9]+.[0-9]+.[0-9]+$" | head -n1)
echo "Latest Rasa OSS version: $LATEST_RASA_VERSION"
echo "LATEST_RASA_VERSION=$LATEST_RASA_VERSION" >> $GITHUB_ENV
- name: Checkout repository 🕝
uses: actions/checkout@v2
- name: Is Rasa OSS version up to date❓
run: |
RASA_VERSION=$(sed -n 's/^rasa==//p' requirements.txt)
echo "RASA_VERSION=$RASA_VERSION" >> $GITHUB_ENV
echo "Current Rasa OSS version: $RASA_VERSION"
if [[ $RASA_VERSION == $LATEST_RASA_VERSION ]]
then
echo "Current version is the the latest one. Nothing to update."
echo "CREATE_PR=false" >> $GITHUB_ENV
else
echo "A newer version $LATEST_RASA_VERSION has found. Bumping it now."
echo "CREATE_PR=true" >> $GITHUB_ENV
fi
- name: Set branch name
if: env.CREATE_PR == 'true'
run: |
echo BRANCH_NAME="Bump-Rasa-OSS-to-${LATEST_RASA_VERSION}" >> $GITHUB_ENV
- name: Check if duplicated PR exists 🔍
if: env.CREATE_PR == 'true'
run: |
# Search all open PRs and
# return the list of matching PRs
gh pr list --state open --search "$BRANCH_NAME"
PRS=$(gh pr list --state open --search "$BRANCH_NAME")
# If $PRS is not empty, we know there is a related PR that bumping Rasa OSS.
if [[ -n $PRS ]]; then
echo "Found related pull request ${BRANCH_NAME}."
echo "Skip the following steps."
echo "CREATE_PR=false" >> $GITHUB_ENV
fi
- name: Create new branch 🐣
if: env.CREATE_PR == 'true'
run: |
git config user.name github-actions
git config user.email [email protected]
git remote update origin --prune
git checkout -b $BRANCH_NAME
- name: Commit and push the version bump
if: env.CREATE_PR == 'true'
run: |
# Bump version
sed -i "s/^rasa==.*/rasa==${LATEST_RASA_VERSION}/" requirements.txt
# Stage modified file
git add -u
# Commit & Push
git commit -m "Bump Rasa OSS to ${LATEST_RASA_VERSION}"
git push -f origin $BRANCH_NAME
- name: Open pull request ☄️
if: env.CREATE_PR == 'true'
env:
# This label will trigger train and test workflow
LABEL: 'tool:train-and-test'
run: |
# Fill pull request title and body with branch name and commits
gh pr create --fill \
--label "$LABEL" \
--reviewer rasa-aadlv,miraai,rasa-jmac,aerowithanl
- name: Comment
if: env.CREATE_PR == 'true'
run: gh pr comment $BRANCH_NAME --body "$(< .github/VERSION_BUMPER_PR_COMMENT.md)"
- name: Notify Slack of failure ⛔
if: failure()
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_INFRA_WEBHOOK }}
uses: Ilshidur/action-slack@689ad44a9c9092315abd286d0e3a9a74d31ab78a
with:
args: "⛔️ Bumping Rasa OSS version failed! Please check out GitHub Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"