Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sailbot workspace ref for other repositories #193

Merged
merged 4 commits into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/test_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@ on:
required: false

jobs:
metadata:
name: Extract metadata
# Adapted from https://github.com/actions/toolkit/issues/1264#issuecomment-1770928498
extract-metadata:
runs-on: ubuntu-latest
permissions:
actions: read
outputs:
caller-sha: ${{ steps.workflows-ref.outputs.caller-sha }}
caller-ref: ${{ steps.workflows-ref.outputs.caller-ref }}
steps:
- name: Get workflow reference
id: workflows-ref
run: |
sha=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.gh-token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/UBCSailbot/sailbot_workspace/actions/runs/${{ github.run_id }} | jq -r '.referenced_workflows[0] | .sha')
echo "caller-sha=$sha" >> $GITHUB_OUTPUT
ref=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.gh-token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/UBCSailbot/${{ inputs.repository }}/actions/runs/${{ github.run_id }} | jq -r '.referenced_workflows[0] | .ref')
echo "caller-ref=$ref" >> $GITHUB_OUTPUT

colcon-test:
runs-on: ubuntu-latest
if: ${{ inputs.ros-ci }}
needs: [metadata]
needs: [extract-metadata]
steps:
- name: Checkout workspace
uses: actions/checkout@v4
with:
repository: UBCSailbot/sailbot_workspace
ref: ${{ needs.metadata.outputs.caller-sha }}
ref: ${{ needs.extract-metadata.outputs.caller-ref }}

- name: Checkout repositories
uses: ./.github/actions/checkout/
Expand All @@ -82,13 +82,13 @@ jobs:
name: ament_${{ matrix.linter }}
runs-on: ubuntu-latest
if: ${{ inputs.ros-ci }}
needs: [metadata]
needs: [extract-metadata]
steps:
- name: Checkout workspace
uses: actions/checkout@v4
with:
repository: UBCSailbot/sailbot_workspace
ref: ${{ needs.metadata.outputs.caller-sha }}
ref: ${{ needs.extract-metadata.outputs.caller-ref }}

- name: Checkout repositories
uses: ./.github/actions/checkout/
Expand All @@ -104,13 +104,13 @@ jobs:
clang-tidy:
runs-on: ubuntu-latest
if: inputs.clang-tidy
needs: [metadata]
needs: [extract-metadata]
steps:
- name: Checkout workspace
uses: actions/checkout@v4
with:
repository: UBCSailbot/sailbot_workspace
ref: ${{ needs.metadata.outputs.caller-sha }}
ref: ${{ needs.extract-metadata.outputs.caller-ref }}

- name: Checkout repositories
uses: ./.github/actions/checkout/
Expand Down