Skip to content

GitHub action to get commit SHA that GitHub Actions reusable workflow was called with

License

Notifications You must be signed in to change notification settings

canonical/get-workflow-version-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get reusable workflow version

GitHub composite action to get commit SHA that GitHub Actions reusable workflow was called with

Workaround for actions/toolkit#1264

When a reusable workflow is called, the github context is always associated with the caller workflow

https://docs.github.com/en/actions/using-workflows/reusing-workflows#overview

If a reusable workflow needs to checkout files (e.g. a Python script) from its repository—instead of the repository of the caller workflow—it needs to know what version it was called with.

Usage

# Reusable workflow (e.g. build_charm.yaml)
on:
  workflow_call:

jobs:
  foo:
    runs-on: ubuntu-latest
    steps:
      - name: Get workflow version
        id: workflow-version
        uses: canonical/get-workflow-version-action@v1
        with:
          # Repository where reusable workflow is located
          repository-name: canonical/data-platform-workflows
          # Name of reusable workflow
          file-name: build_charm.yaml
          # Only required for private repositories
          github-token: ${{ secrets.GITHUB_TOKEN }}
      # Use the version. For example:
      - name: Install Python CLI
        run: pipx install git+https://github.com/canonical/data-platform-workflows@'${{ steps.workflow-version.outputs.sha }}'#subdirectory=python/cli
    # Only required for private repositories
    permissions:
      actions: read  # Needed for GitHub API call to get workflow version
      

About

GitHub action to get commit SHA that GitHub Actions reusable workflow was called with

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages