-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (67 loc) · 2.51 KB
/
dependabot-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
76
77
78
79
80
81
name: Approve Dependabot PRs and Create Release
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
permissions:
contents: write
pull-requests: write
issues: write
actions: write
jobs:
approve-dependabot-pr:
if: ${{ github.event_name == 'pull_request_target' && (github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Approve Dependabot PR
run: |
gh pr review ${{ github.event.pull_request.number }} --approve
env:
GH_TOKEN: ${{ secrets.PAM_REPO }}
- name: Merge Dependabot PR
run: |
gh pr merge ${{ github.event.pull_request.number }} --merge --delete-branch
env:
GH_TOKEN: ${{ secrets.PAM_REPO }}
create-release:
needs: approve-dependabot-pr
if: ${{ github.event_name == 'pull_request_target' && (github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') }}
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.get_latest_version.outputs.new_version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get the latest release version
id: get_latest_version
run: |
latest_release=$(gh release view --json tagName --jq .tagName || echo "v0.0.0")
echo "Latest release version: $latest_release"
IFS='.' read -r major minor patch <<< "${latest_release#v}"
new_patch=$((patch+1))
new_version="v${major}.${minor}.${new_patch}"
echo "New version: $new_version"
echo "::set-output name=new_version::$new_version"
- name: Create draft release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.PAM_REPO }}
run: |
gh release create ${{ steps.get_latest_version.outputs.new_version }} -d -t "Release ${{ steps.get_latest_version.outputs.new_version }}" -n "Automated release by GitHub Actions"
approve-release:
needs: create-release
if: ${{ github.event_name == 'pull_request_target' && (github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]') }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Publish draft release
env:
GITHUB_TOKEN: ${{ secrets.PAM_REPO }}
run: |
gh release edit ${{ needs.create-release.outputs.new_version }} --draft=false