branch-names/.github/workflows/test.yml

72 lines
3.0 KiB
YAML
Raw Normal View History

2020-12-11 21:15:40 +08:00
name: CI
on:
push:
2021-04-24 18:46:27 +08:00
tags:
- '*'
2020-12-11 21:15:40 +08:00
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
2021-04-24 18:46:27 +08:00
if: "!startsWith(github.ref, 'refs/tags/')"
2020-12-11 22:12:15 +08:00
run: |
2021-02-08 08:41:26 +08:00
echo "Current Branch: ${{ steps.branch-name.outputs.current_branch }}"
echo "Base Ref: ${{ steps.branch-name.outputs.base_ref_branch }}"
echo "Head Ref: ${{ steps.branch-name.outputs.head_ref_branch }}"
echo "Ref: ${{ steps.branch-name.outputs.ref_branch }}"
2021-02-13 18:39:40 +08:00
echo "Is Default: ${{ steps.branch-name.outputs.is_default }}"
- name: Check is_default for pull request
2021-04-24 18:46:27 +08:00
if: github.event_name == 'pull_request' && !startsWith(github.ref, 'refs/tags/') && steps.branch-name.outputs.is_default != 'false'
2021-02-13 18:39:40 +08:00
run: |
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
exit 1
- name: Check is_default for non pull request
2021-04-24 18:46:27 +08:00
if: github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/tags/') && steps.branch-name.outputs.is_default != 'true'
2021-02-13 18:39:40 +08:00
run: |
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
exit 1
2020-12-11 21:48:51 +08:00
- name: Test base ref output
2021-04-24 18:46:27 +08:00
if: github.event_name == 'pull_request' && !startsWith(github.ref, 'refs/tags/') && !steps.branch-name.outputs.base_ref_branch
2020-12-11 21:48:51 +08:00
run: |
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
exit 1
- name: Test head ref output
2021-04-24 18:46:27 +08:00
if: github.event_name == 'pull_request' && !startsWith(github.ref, 'refs/tags/') && !steps.branch-name.outputs.head_ref_branch
2020-12-11 21:48:51 +08:00
run: |
echo "Head ref unset: ${{ steps.branch-name.outputs.head_ref_branch }}"
exit 1
- name: Test ref output
2021-04-24 18:46:27 +08:00
if: "!steps.branch-name.outputs.ref_branch && !startsWith(github.ref, 'refs/tags/') "
2020-12-11 21:48:51 +08:00
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.
2021-04-24 18:46:27 +08:00
if: github.event_name == 'pull_request' && !startsWith(github.ref, 'refs/tags/') && !steps.branch-name.outputs.current_branch
2021-02-08 08:34:33 +08:00
run: |
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
exit 1
- name: Test current branch output for push event.
2021-04-24 18:46:27 +08:00
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') && !steps.branch-name.outputs.current_branch
2021-02-08 08:34:33 +08:00
run: |
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
exit 1
2021-04-24 18:46:27 +08:00
- name: Test current tag for push events.
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !steps.branch-name.outputs.tag
run: |
echo "Current tag unset: ${{ steps.branch-name.outputs.tag }}"
exit 1
2021-02-08 08:34:33 +08:00