-
Notifications
You must be signed in to change notification settings - Fork 13
102 lines (88 loc) · 3.27 KB
/
push_network.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
---
# push workflow is shared and expected to perform actions after a merge happens
# on a maintenance branch (default or release). For example updating the
# draft release-notes.
# based on great work from
# https://github.com/T-Systems-MMS/ansible-collection-icinga-director
name: push_network
on:
workflow_call:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
inputs:
repo:
description: Repository url
required: true
type: string
secrets:
BOT_PAT:
description: Bot secret
required: true
jobs:
update_release_draft:
runs-on: ubuntu-24.04
environment: push
steps:
- uses: actions/checkout@v4
with:
repository: ${{ inputs.repo }}
fetch-depth: 0
token: ${{ secrets.BOT_PAT }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install antsibull-changelog, antsichaut
run: >
python3 -m pip install
antsibull-changelog
git+https://github.com/ansible-community/antsichaut.git
pre-commit
--disable-pip-version-check
- name: Run release drafter
id: release_drafter
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove the v prefix from the release drafter version
run: |
VERSION=${{ steps.release_drafter.outputs.tag_name }}
echo "VERSION=${VERSION#v}" >> $GITHUB_ENV
- name: Generate new version in changelog.yaml
run: antsibull-changelog release -v --version "${{ env.VERSION }}"
- name: Get previous tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
## this part is commented out to check push workflow
## ref - https://github.com/ansible-collections/cisco.nxos/pull/765
# - name: Generate changelog.yaml
# run: antsichaut
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SINCE_VERSION: "${{ steps.previoustag.outputs.tag }}"
# - name: Update Changelog.rst
# run: antsibull-changelog generate -v
- name: Cleanup to use prettier
run: pre-commit run prettier --all-files
continue-on-error: true
- name: Update the galaxy.yml version
run: |
sed -i -e 's/version:.*/version: ${{ env.VERSION }}/' galaxy.yml
- name: Determine if a PR is necessary
run: git diff --no-ext-diff --quiet --exit-code
continue-on-error: true
id: pr_check
- name: Create PR for changelog
run: |
git config user.name "Ansible Bot"
git config user.email [email protected]
git checkout -t -b ${{ env.BRANCH_NAME }}
git add .
git commit -m "Changelog updated"
git push origin ${{ env.BRANCH_NAME }}
gh pr create --title "Changelog updated" --body "Changelog updated" --base main
if: steps.pr_check.outcome == 'failure'
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
BRANCH_NAME: chore-${{ github.workflow }}-${{ github.run_number }}