Skip to content

Commit f3190e1

Browse files
committed
Add check build trigger [cd build]
1 parent 5eff809 commit f3190e1

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,39 @@ on:
1414
types: [published]
1515

1616
jobs:
17+
echo_github_env:
18+
name: Echo env variables
19+
runs-on: ubuntu-latest
20+
steps:
21+
- run: |
22+
echo "github.event.action : ${{ github.event.action }}"
23+
echo "github.event_name : ${{ github.event_name }}"
24+
echo "github.ref : ${{ github.ref }}"
25+
echo "github.ref_type : ${{ github.ref_type }}"
26+
echo "github.event.ref : ${{ github.event.ref }}"
27+
28+
# Check whether to build the wheels and the source tarball
29+
check_build_trigger:
30+
name: Check build trigger
31+
runs-on: ubuntu-latest
32+
# Not for forks
33+
if: github.repository == 'pythainlp/pythainlp'
34+
outputs:
35+
build: ${{ steps.check_build_trigger.outputs.build }}
36+
steps:
37+
- name: Checkout source code
38+
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ github.event.pull_request.head.sha }}
41+
- id: check_build_trigger
42+
name: Check build trigger
43+
run: bash build_tools/github/check_build_trigger.sh
44+
# To trigger the build steps, add "[cd build]" to commit message
45+
1746
build:
1847
name: Build and check distributions
48+
needs: [check_build_trigger]
1949
runs-on: ubuntu-latest
20-
if: contains(github.event.head_commit.message, '[cd build]')
2150
strategy:
2251
matrix:
2352
python-version: ["3.12"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
COMMIT_MSG=$(git log --no-merges -1 --oneline)
7+
8+
# The commit marker "[cd build]" will trigger the build when required
9+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ||
10+
"$GITHUB_EVENT_NAME" == "release" ||
11+
"$COMMIT_MSG" =~ "[cd build]" ]]; then
12+
echo "build=true" >> $GITHUB_OUTPUT
13+
fi

0 commit comments

Comments
 (0)