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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
---
permissions: read-all
on:
workflow_call:
# Map the workflow outputs to job outputs
outputs:
last_release_ref:
description: "Ref to last release"
value: ${{ jobs.configure.outputs.last_release_ref }}
test_ref:
description: "Ref in test repo to be used"
value: ${{ jobs.configure.outputs.test_ref }}
lib_ref:
description: "Ref in lib repo to be used"
value: ${{ jobs.configure.outputs.lib_ref }}
tools_version:
description: "tools version in tool repo to be used"
value: ${{ jobs.configure.outputs.tools_version }}
# This workflow configures variables that are useful for other jobs. Other
# jobs that depend on this one can access the variables via
# needs.<job-name>.outputs.<variable-name>
jobs:
configure:
runs-on: [self-hosted, linux]
outputs:
last_release_ref: ${{ env.last_release_ref }}
test_ref: ${{ env.test_ref }}
lib_ref: ${{ env.lib_ref }}
tools_version: ${{env.tools_version}}
env:
last_release_ref: ''
test_ref: ''
lib_ref: ''
tools_version: ''
steps:
- name: Cleanup workspace (Linux)
if: always() && runner.os == 'Linux'
run: sudo rm -rf ..?* .[!.]* *
# Get ref of last release.
- name: Checkout PR branch and all history
uses: actions/checkout@v4
with:
path: source
fetch-depth: 0
ref: '${{ github.event.pull_request.head.sha }}'
- name: Get tools version
run: |
cd source
# Extract the version from version.txt and store it in a variable
echo "tools_version=$(cat version.txt)" >> $GITHUB_ENV
- name: Get ref of last release
id: run
run: |
cd source
echo "last_release_ref=$(git describe --abbrev=0 --tags --match=v*)" \
>> $GITHUB_ENV
# Get ref of test to be used. If this is a pull request prefer a branch
# of the same name as the branch being merged into otherwise try to use a
# branch of the same name otherwise use main
- name: Checkout tests from base_ref
if: github.base_ref
id: check-tests-from-base_ref
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ vars.TEST_REPO }}
token: ${{ secrets.TEST_REPO_TOKEN }}
path: tests
fetch-depth: 0
ref: ${{ github.base_ref }}
- name: Use tests from base_ref
if: steps.check-tests-from-base_ref.outcome == 'success'
id: use-tests-from-base_ref
run: |
echo "test_ref=${{ github.base_ref }}" >> $GITHUB_ENV
- name: Checkout tests from ref_name
if: steps.check-tests-from-base_ref.outcome != 'success'
id: check-tests-from-ref_name
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ vars.TEST_REPO }}
token: ${{ secrets.TEST_REPO_TOKEN }}
path: tests
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Use tests from ref_name
if: steps.check-tests-from-ref_name.outcome == 'success'
id: use-tests-from-ref_name
run: |
echo "test_ref=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Use tests from default
if: >
steps.check-tests-from-base_ref.outcome != 'success'
&& steps.check-tests-from-ref_name.outcome != 'success'
run: |
echo "test_ref=main" >> $GITHUB_ENV
# Get ref of lib to be used. If this is a pull request prefer a branch
# of the same name as the branch being merged into otherwise try to use a
# branch of the same name otherwise use main
- name: Checkout lib from base_ref
if: github.base_ref
id: check-lib-from-base_ref
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ vars.DISP_REPO }}
token: ${{ secrets.DISP_REPO_TOKEN }}
path: lib
fetch-depth: 0
ref: ${{ github.base_ref }}
- name: Use lib from base_ref
if: steps.check-lib-from-base_ref.outcome == 'success'
id: use-lib-from-base_ref
run: |
echo "lib_ref=${{ github.base_ref }}" >> $GITHUB_ENV
- name: Checkout lib from ref_name
if: steps.check-lib-from-base_ref.outcome != 'success'
id: check-lib-from-ref_name
uses: actions/checkout@v4
continue-on-error: true
with:
repository: ${{ vars.DISP_REPO }}
token: ${{ secrets.DISP_REPO_TOKEN }}
path: lib
fetch-depth: 0
ref: ${{ github.ref_name }}
- name: Use lib from ref_name
if: steps.check-lib-from-ref_name.outcome == 'success'
id: use-lib-from-ref_name
run: |
echo "lib_ref=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Use lib from default
if: >
steps.check-lib-from-base_ref.outcome != 'success'
&& steps.check-lib-from-ref_name.outcome != 'success'
run: |
echo "lib_ref=main" >> $GITHUB_ENV
- name: Report
if: always()
run: |
echo "last_release_ref=${{ env.last_release_ref }}"
echo "test_ref=${{ env.test_ref }}"
echo "lib_ref=${{ env.lib_ref }}"
- name: Cleanup workspace (Linux)
if: always() && runner.os == 'Linux'
run: sudo rm -rf ..?* .[!.]* *
|