feat: use github variable

This commit is contained in:
bestony 2021-01-16 15:56:38 +08:00
parent d27ea5c8dc
commit 848e9cf058
4 changed files with 3 additions and 28 deletions

View File

@ -6,16 +6,7 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
TRAVIS_REPO_SLUG: ${{ github.repository }}
TRAVIS_BRANCH: master
TRAVIS_PULL_REQUEST: ${{ github.event.number }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps: steps:
- name: Set ENV variables
run: |
echo "::set-env name=TRAVIS_BRANCH::${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}"
echo "::set-env name=TRAVIS_EVENT_TYPE::$(if [ "schedule" == "${{ github.event_name }}" ]; then echo "cron"; else echo "${{ github.event_name }}"; fi)"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@ -7,15 +7,8 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
TRAVIS_REPO_SLUG: ${{ github.repository }} PULL_REQUEST_ID: ${{ github.event.number }}
TRAVIS_BRANCH: master
TRAVIS_PULL_REQUEST: ${{ github.event.number }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps: steps:
- name: Set ENV variables
run: |
echo "::set-env name=TRAVIS_BRANCH::${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}"
echo "::set-env name=TRAVIS_EVENT_TYPE::$(if [ "schedule" == "${{ github.event_name }}" ]; then echo "cron"; else echo "${{ github.event_name }}"; fi)"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@ -7,16 +7,7 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env:
TRAVIS_REPO_SLUG: ${{ github.repository }}
TRAVIS_BRANCH: master
TRAVIS_PULL_REQUEST: ${{ github.event.number }}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps: steps:
- name: Set ENV variables
run: |
echo "::set-env name=TRAVIS_BRANCH::${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')}"
echo "::set-env name=TRAVIS_EVENT_TYPE::$(if [ "schedule" == "${{ github.event_name }}" ]; then echo "cron"; else echo "${{ github.event_name }}"; fi)"
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@ -11,11 +11,11 @@ set -e
echo "[收集] 计算 PR 分支与目标分支的分叉点……" echo "[收集] 计算 PR 分支与目标分支的分叉点……"
TARGET_BRANCH="${TRAVIS_BRANCH:-master}" TARGET_BRANCH="${GITHUB_BASE_REF:-master}"
echo "[收集] 目标分支设定为:${TARGET_BRANCH}" echo "[收集] 目标分支设定为:${TARGET_BRANCH}"
MERGE_BASE='HEAD^' MERGE_BASE='HEAD^'
[ "$TRAVIS_PULL_REQUEST" != 'false' ] \ [ "$PULL_REQUEST_ID" != 'false' ] \
&& MERGE_BASE="$(git merge-base "$TARGET_BRANCH" HEAD)" && MERGE_BASE="$(git merge-base "$TARGET_BRANCH" HEAD)"
echo "[收集] 找到分叉节点:${MERGE_BASE}" echo "[收集] 找到分叉节点:${MERGE_BASE}"