diff --git a/.github/workflows/assemble_multiarch_image.yaml b/.github/workflows/assemble_multiarch_image.yaml index 6680860..db679d1 100644 --- a/.github/workflows/assemble_multiarch_image.yaml +++ b/.github/workflows/assemble_multiarch_image.yaml @@ -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 @@ -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