Skip to content

Commit 9a17e3f

Browse files
committed
debug
1 parent 063f353 commit 9a17e3f

File tree

1 file changed

+74
-77
lines changed

1 file changed

+74
-77
lines changed

.github/workflows/release-pr.yaml

Lines changed: 74 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,84 @@
1-
# name: Release-PR
2-
# on:
3-
# pull_request:
4-
# types: [closed]
51
name: Release-PR
62
on:
73
pull_request:
4+
types: [closed]
85

96
jobs:
10-
# Pre-Check:
11-
# if: |
12-
# github.event.pull_request.merged &&
13-
# endsWith(github.event.pull_request.title, '/workflows/release-pr') &&
14-
# github.event.pull_request.user.login != 'polywrap-build-bot'
15-
# runs-on: ubuntu-18.04
16-
# steps:
17-
# - name: Checkout
18-
# uses: actions/checkout@v3
19-
# with:
20-
# ref: ${{github.event.pull_request.base.ref}}
21-
22-
# - name: Pull-Request Creator Is Publisher?
23-
# run: |
24-
# exists=$(echo $(grep -Fxcs ${CREATOR} .github/PUBLISHERS))
25-
# if [ "$exists" == "1" ] ; then
26-
# echo IS_PUBLISHER=true >> $GITHUB_ENV
27-
# else
28-
# echo IS_PUBLISHER=false >> $GITHUB_ENV
29-
# fi
30-
# env:
31-
# CREATOR: ${{github.event.pull_request.user.login}}
32-
33-
# - name: Creator Is Not Publisher...
34-
# if: env.IS_PUBLISHER == 'false'
35-
# uses: actions/github-script@0.8.0
36-
# with:
37-
# github-token: ${{secrets.GITHUB_TOKEN}}
38-
# script: |
39-
# github.issues.createComment({
40-
# issue_number: context.issue.number,
41-
# owner: context.repo.owner,
42-
# repo: context.repo.repo,
43-
# body: '${{github.event.pull_request.user.login}} is not a PUBLISHER. Please see the .github/PUBLISHERS file...'
44-
# })
45-
46-
# - name: Read VERSION into env.RELEASE_VERSION
47-
# run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
48-
49-
# - name: Tag Exists?
50-
# id: tag_check
51-
# shell: bash -ex {0}
52-
# run: |
53-
# GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}"
54-
# http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
55-
# -H "Authorization: token ${GITHUB_TOKEN}")
56-
# if [ "$http_status_code" -ne "404" ] ; then
57-
# echo TAG_EXISTS=true >> $GITHUB_ENV
58-
# else
59-
# echo TAG_EXISTS=false >> $GITHUB_ENV
60-
# fi
61-
# env:
62-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
64-
# - name: Release Already Exists...
65-
# if: env.TAG_EXISTS == 'true'
66-
# uses: actions/github-script@0.8.0
67-
# with:
68-
# github-token: ${{secrets.GITHUB_TOKEN}}
69-
# script: |
70-
# github.issues.createComment({
71-
# issue_number: context.issue.number,
72-
# owner: context.repo.owner,
73-
# repo: context.repo.repo,
74-
# body: '[Release Already Exists](https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}) (`${{env.RELEASE_VERSION}}`)'
75-
# })
76-
77-
# - name: Fail If Conditions Aren't Met...
78-
# if: |
79-
# env.IS_PUBLISHER != 'true' ||
80-
# env.TAG_EXISTS != 'false'
81-
# run: exit 1
7+
Pre-Check:
8+
if: |
9+
github.event.pull_request.merged &&
10+
endsWith(github.event.pull_request.title, '/workflows/release-pr') &&
11+
github.event.pull_request.user.login != 'polywrap-build-bot'
12+
runs-on: ubuntu-18.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
ref: ${{github.event.pull_request.base.ref}}
18+
19+
- name: Pull-Request Creator Is Publisher?
20+
run: |
21+
exists=$(echo $(grep -Fxcs ${CREATOR} .github/PUBLISHERS))
22+
if [ "$exists" == "1" ] ; then
23+
echo IS_PUBLISHER=true >> $GITHUB_ENV
24+
else
25+
echo IS_PUBLISHER=false >> $GITHUB_ENV
26+
fi
27+
env:
28+
CREATOR: ${{github.event.pull_request.user.login}}
29+
30+
- name: Creator Is Not Publisher...
31+
if: env.IS_PUBLISHER == 'false'
32+
uses: actions/github-script@0.8.0
33+
with:
34+
github-token: ${{secrets.GITHUB_TOKEN}}
35+
script: |
36+
github.issues.createComment({
37+
issue_number: context.issue.number,
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
body: '${{github.event.pull_request.user.login}} is not a PUBLISHER. Please see the .github/PUBLISHERS file...'
41+
})
42+
43+
- name: Read VERSION into env.RELEASE_VERSION
44+
run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
45+
46+
- name: Tag Exists?
47+
id: tag_check
48+
shell: bash -ex {0}
49+
run: |
50+
GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}"
51+
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
52+
-H "Authorization: token ${GITHUB_TOKEN}")
53+
if [ "$http_status_code" -ne "404" ] ; then
54+
echo TAG_EXISTS=true >> $GITHUB_ENV
55+
else
56+
echo TAG_EXISTS=false >> $GITHUB_ENV
57+
fi
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Release Already Exists...
62+
if: env.TAG_EXISTS == 'true'
63+
uses: actions/github-script@0.8.0
64+
with:
65+
github-token: ${{secrets.GITHUB_TOKEN}}
66+
script: |
67+
github.issues.createComment({
68+
issue_number: context.issue.number,
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
body: '[Release Already Exists](https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}) (`${{env.RELEASE_VERSION}}`)'
72+
})
73+
74+
- name: Fail If Conditions Aren't Met...
75+
if: |
76+
env.IS_PUBLISHER != 'true' ||
77+
env.TAG_EXISTS != 'false'
78+
run: exit 1
8279

8380
Release-PR:
84-
# needs: Pre-Check
81+
needs: Pre-Check
8582
runs-on: ubuntu-18.04
8683
steps:
8784
- name: Checkout

0 commit comments

Comments
 (0)