Skip to content

Commit

Permalink
Apply workaround from actions/toolkit#1264 to find workflow ref
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Jan 30, 2024
1 parent eb38894 commit 4a8e96d
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions .github/workflows/assemble_multiarch_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,37 @@ jobs:
name: Create Mulitarch Manifest
runs-on: ubuntu-22.04
steps:
- name: Get Workflow Reference
id: workflow-ref
- name: Checkout calling repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get workflow reference
id: workflows-ref
run: |
if [ -n "${{ github.workflow_ref }}" ]; then
IFS='@' read -r WORKFLOW_REPO WORKFLOW_REF << ${{ github.workflow_ref }}
echo "WORKFLOW_REPO=$WORKFLOW_REPO" >> $GITHUB_ENV
echo "WORKFLOW_REF=$WORKFLOW_REF" >> $GITHUB_ENV
fi
- uses: actions/checkout@v4.1.1
workflow_ref=${{ github.workflow_ref }}
repository="${{ github.repository }}/"
repo_ref="@${{ github.ref }}"
workflow_path=${workflow_ref#"$repository"}
workflow_path=${workflow_path%"$repo_ref"}
ref=$(cat ${workflow_path} | grep assemble_multiarch_image | cut -d"@" -f2)
echo "ref=${ref}" >> ${GITHUB_OUTPUT}
- name: Checkout workflows
uses: actions/checkout@v4
with:
repository: ${{ env.WORKFLOW_REPO || github.repository }}
ref: ${{ env.WORKFLOW_REF }}
repository: canonical/k8s-workflows
ref: ${{ steps.workflows-ref.outputs.ref }}
path: workflows
token: ${{ secrets.GITHUB_TOKEN }}

- id: assemble-image-tags-js
uses: juliangruber/read-file-action@v1
with:
path: .github/files/assemble-image-tags.js
path: workflows/.github/files/assemble-image-tags.js
trim: true

- name: Assemble Image Tags
id: assemble-image-tags
uses: actions/github-script@v7.0.1
Expand All @@ -46,17 +60,20 @@ jobs:
const rockMetas = JSON.parse(`${{ inputs.rock-metas }}`)
${{ steps.assemble-image-tags-js.outputs.content }}
await main(rockMetas)
- name: Login to Container Registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- id: create-and-push-manifest-js
uses: juliangruber/read-file-action@v1
with:
path: .github/files/create-and-push-manifest.js
path: workflows/.github/files/create-and-push-manifest.js
trim: true

- name: Create and Push Manifests
id: create-and-push-manifest
uses: actions/github-script@v7.0.1
Expand Down

0 comments on commit 4a8e96d

Please sign in to comment.