-
-
Notifications
You must be signed in to change notification settings - Fork 27
88 lines (85 loc) · 3.98 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: CI
on:
push:
tags:
- '*'
branches:
- main
release:
types: [published, created]
pull_request:
branches:
- main
jobs:
test:
name: Test branch-names
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Run test
id: branch-names
uses: ./
- name: Show output
run: |
echo "Default Branch: ${{ steps.branch-names.outputs.default_branch }}"
echo "Current Branch: ${{ steps.branch-names.outputs.current_branch }}"
echo "Base Ref: ${{ steps.branch-names.outputs.base_ref_branch }}"
echo "Head Ref: ${{ steps.branch-names.outputs.head_ref_branch }}"
echo "Ref: ${{ steps.branch-names.outputs.ref_branch }}"
echo "Is Default: ${{ steps.branch-names.outputs.is_default }}"
echo "Is Tag: ${{ steps.branch-names.outputs.is_tag }}"
echo "Current tag: ${{ steps.branch-names.outputs.tag }}"
- name: Test is_default output for pull request
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default != 'false'
run: |
echo "Is default is invalid: ${{ steps.branch-names.outputs.is_default }}"
exit 1
- name: Test is_default output for non pull request
if: "!contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default != 'true'"
run: |
echo "Is default is invalid: ${{ steps.branch-names.outputs.is_default }}"
exit 1
- name: Test base_ref_branch output
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.base_ref_branch
run: |
echo "Base ref unset: ${{ steps.branch-names.outputs.base_ref_branch }}"
exit 1
- name: Test head_ref output
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.head_ref_branch
run: |
echo "Head ref unset: ${{ steps.branch-names.outputs.head_ref_branch }}"
exit 1
- name: Test ref_branch output
if: "!steps.branch-names.outputs.ref_branch && steps.branch-names.outputs.is_tag == 'false'"
run: |
echo "Ref unset: ${{ steps.branch-names.outputs.ref_branch }}"
exit 1
- name: Test current_branch output for pull_request or pull_request_target event.
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.current_branch
run: |
echo "Current branch unset: ${{ steps.branch-names.outputs.current_branch }}"
exit 1
- name: Test current_branch output for push event.
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.current_branch
run: |
echo "Current branch unset: ${{ steps.branch-names.outputs.current_branch }}"
exit 1
- name: Test current_branch output for tag based push event.
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'true' && !steps.branch-names.outputs.base_ref_branch
run: |
echo "Base ref unset: ${{ steps.branch-names.outputs.base_ref_branch }}"
exit 1
- name: Test tag output for tag based push event.
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'true' && !steps.branch-names.outputs.tag
run: |
echo "Current tag unset: ${{ steps.branch-names.outputs.tag }}"
exit 1