-
Notifications
You must be signed in to change notification settings - Fork 119
63 lines (58 loc) · 1.96 KB
/
push-prerelease.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
# (C) 2024 GoodData Corporation
name: Push ~ Prerelease
on:
push:
branches:
- master
- release
jobs:
pull-request-info:
runs-on:
group: infra1-runners-arc
labels: runners-small
outputs:
should-prerelease: ${{ steps.should-prerelease.outputs.result }}
author: ${{ steps.author.outputs.result }}
branch-name: ${{ steps.extract-branch.outputs.branch }}
steps:
- uses: actions/github-script@v7
id: should-prerelease
with:
script: |
const pullRequests = await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
});
return pullRequests?.data[0]?.labels?.some((it)=>it.name==='publish pre-release');
result-encoding: string
- uses: actions/github-script@v7
id: author
with:
script: |
const pullRequests = await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
});
return pullRequests?.data[0]?.user?.login;
result-encoding: string
- name: Extract branch name
env:
CURRENT_REF: ${{ github.event.ref }}
id: extract-branch
shell: bash
run: echo "branch=${CURRENT_REF#refs/heads/}" >> $GITHUB_OUTPUT
publish-pre-release:
needs: [pull-request-info]
name: Publish pre-release
# should-prerelease is a string, not a boolean
if: ${{ needs.pull-request-info.outputs.should-prerelease == 'true' }}
uses: ./.github/workflows/rw-publish-prerelease.yml
secrets: inherit
permissions:
contents: write
id-token: write
with:
source-branch: ${{ needs.pull-request-info.outputs.branch-name }}
author-name: ${{ needs.pull-request-info.outputs.author }}