-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (53 loc) · 1.88 KB
/
test-create-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
name: Test the create-release action
on:
workflow_dispatch:
branches: '*'
pull_request:
branches: main
paths:
- create-release/**
- .github/workflows/test-create-release.yml
push:
branches: main
paths:
- create-release/**
- .github/workflows/test-create-release.yml
jobs:
test-create-release:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4 # Need to checkout first to use current repo during testing
- uses: ./create-release # ottofeller/github-actions/create-release@main
id: create-release
with:
initial-version: 0.0.1
release-branches: ${{ github.ref }}
bump-level: patch
github-token: ${{ secrets.GITHUB_TOKEN }}
# Since we are testing, clean up after the run and delete the release
- uses: dev-drprasad/[email protected]
with:
delete_release: false
tag_name: ${{ steps.create-release.outputs.release-name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The previous action fails to find a draft release.
# Thus need to delete it manually with octokit.
- uses: actions/github-script@v7
env:
RELEASE_ID: ${{ steps.create-release.outputs.release-id }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const release_id = process.env.RELEASE_ID
const { owner, repo } = context.repo
try {
await github.rest.repos.deleteRelease({ owner, repo, release_id })
console.log(`✅ Release "${release_id}" deleted successfully!`)
} catch (e) {
console.error(e)
core.setFailed(`❌ Release "${release_id}" not deleted!`);
}