89 lines
4.0 KiB
YAML
Raw Normal View History

2020-12-11 08:15:40 -05:00
name: CI
on:
push:
2021-04-24 06:46:27 -04:00
tags:
- '*'
2020-12-11 08:15:40 -05:00
branches:
- main
release:
types: [published, created]
2020-12-11 08:15:40 -05:00
pull_request:
branches:
- main
jobs:
test:
2024-02-06 20:52:54 -07:00
name: Test branch-names
2021-12-18 20:08:16 -05:00
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
2022-12-15 18:31:33 -07:00
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, windows-2022]
2021-12-18 20:08:16 -05:00
2020-12-11 08:15:40 -05:00
steps:
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
2022-11-12 15:52:34 -07:00
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
2022-11-12 15:59:27 -07:00
run: echo "$GITHUB_CONTEXT"
2020-12-11 08:21:28 -05:00
- name: Run test
2024-02-06 20:52:54 -07:00
id: branch-names
2020-12-11 08:21:28 -05:00
uses: ./
- name: Show output
2020-12-11 09:12:15 -05:00
run: |
2024-02-06 20:52:54 -07:00
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 }}"
2021-05-27 08:31:09 -04:00
- name: Test is_default output for pull request
2024-02-06 20:52:54 -07:00
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default != 'false'
2021-02-13 05:39:40 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Is default is invalid: ${{ steps.branch-names.outputs.is_default }}"
2021-02-13 05:39:40 -05:00
exit 1
2021-05-27 08:31:09 -04:00
- name: Test is_default output for non pull request
2024-02-06 20:52:54 -07:00
if: "!contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && steps.branch-names.outputs.is_default != 'true'"
2021-02-13 05:39:40 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Is default is invalid: ${{ steps.branch-names.outputs.is_default }}"
2021-02-13 05:39:40 -05:00
exit 1
2021-05-27 08:31:09 -04:00
- name: Test base_ref_branch output
2024-02-06 20:52:54 -07:00
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.base_ref_branch
2020-12-11 08:48:51 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Base ref unset: ${{ steps.branch-names.outputs.base_ref_branch }}"
2020-12-11 08:48:51 -05:00
exit 1
2021-05-27 08:31:09 -04:00
- name: Test head_ref output
2024-02-06 20:52:54 -07:00
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.head_ref_branch
2020-12-11 08:48:51 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Head ref unset: ${{ steps.branch-names.outputs.head_ref_branch }}"
2020-12-11 08:48:51 -05:00
exit 1
2021-05-27 08:31:09 -04:00
- name: Test ref_branch output
2024-02-06 20:52:54 -07:00
if: "!steps.branch-names.outputs.ref_branch && steps.branch-names.outputs.is_tag == 'false'"
2020-12-11 08:48:51 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Ref unset: ${{ steps.branch-names.outputs.ref_branch }}"
2020-12-11 08:48:51 -05:00
exit 1
2022-11-12 20:56:54 -07:00
- name: Test current_branch output for pull_request or pull_request_target event.
2024-02-06 20:52:54 -07:00
if: contains(github.event_name, 'pull_request') && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.current_branch
2021-02-07 19:34:33 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Current branch unset: ${{ steps.branch-names.outputs.current_branch }}"
2021-02-07 19:34:33 -05:00
exit 1
2021-05-27 08:31:09 -04:00
- name: Test current_branch output for push event.
2024-02-06 20:52:54 -07:00
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'false' && !steps.branch-names.outputs.current_branch
2021-02-07 19:34:33 -05:00
run: |
2024-02-06 20:52:54 -07:00
echo "Current branch unset: ${{ steps.branch-names.outputs.current_branch }}"
2021-02-07 19:34:33 -05:00
exit 1
2021-05-27 08:31:09 -04:00
- name: Test current_branch output for tag based push event.
2024-02-06 20:52:54 -07:00
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'true' && !steps.branch-names.outputs.base_ref_branch
2021-05-27 08:31:09 -04:00
run: |
2024-02-06 20:52:54 -07:00
echo "Base ref unset: ${{ steps.branch-names.outputs.base_ref_branch }}"
2021-05-27 08:31:09 -04:00
exit 1
- name: Test tag output for tag based push event.
2024-02-06 20:52:54 -07:00
if: github.event_name == 'push' && steps.branch-names.outputs.is_tag == 'true' && !steps.branch-names.outputs.tag
2021-04-24 06:46:27 -04:00
run: |
2024-02-06 20:52:54 -07:00
echo "Current tag unset: ${{ steps.branch-names.outputs.tag }}"
2021-04-24 06:46:27 -04:00
exit 1