2020-12-11 21:15:40 +08:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Test branch-name
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2020-12-11 21:21:28 +08:00
|
|
|
- name: Run test
|
|
|
|
id: branch-name
|
|
|
|
uses: ./
|
|
|
|
- name: Show output
|
2020-12-11 22:12:15 +08:00
|
|
|
run: |
|
2020-12-11 21:21:28 +08:00
|
|
|
echo "${{ steps.branch-name.outputs.base_ref_branch }}"
|
|
|
|
echo "${{ steps.branch-name.outputs.head_ref_branch }}"
|
|
|
|
echo "${{ steps.branch-name.outputs.ref_branch }}"
|
2020-12-11 21:48:51 +08:00
|
|
|
- name: Test base ref output
|
|
|
|
if: github.event_name == 'pull_request' && !steps.branch-name.outputs.base_ref_branch
|
|
|
|
run: |
|
|
|
|
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
|
|
|
|
exit 1
|
|
|
|
- name: Test head ref output
|
|
|
|
if: github.event_name == 'pull_request' && !steps.branch-name.outputs.head_ref_branch
|
|
|
|
run: |
|
|
|
|
echo "Head ref unset: ${{ steps.branch-name.outputs.head_ref_branch }}"
|
|
|
|
exit 1
|
|
|
|
- name: Test ref output
|
|
|
|
if: "!steps.branch-name.outputs.ref_branch"
|
|
|
|
run: |
|
|
|
|
echo "Ref unset: ${{ steps.branch-name.outputs.ref_branch }}"
|
|
|
|
exit 1
|
2021-02-08 08:34:33 +08:00
|
|
|
- name: Test current branch output for pull_request event.
|
|
|
|
if: github.event_name == 'pull_request' && !steps.branch-name.outputs.current_branch
|
|
|
|
run: |
|
|
|
|
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
|
|
|
exit 1
|
|
|
|
- name: Test current branch output for push event.
|
|
|
|
if: github.event_name == 'push' && !steps.branch-name.outputs.current_branch
|
|
|
|
run: |
|
|
|
|
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
|
|
|
exit 1
|
|
|
|
|