diff --git a/.github/workflows/test-ref-branch.yml b/.github/workflows/test-ref-branch.yml new file mode 100644 index 0000000..ecb5b6d --- /dev/null +++ b/.github/workflows/test-ref-branch.yml @@ -0,0 +1,23 @@ +name: Test reference branch + +on: + push: + release: + types: [published] + +jobs: + test-ref-branch: + runs-on: ubuntu-latest + + steps: + - name: Checkout default repository + uses: actions/checkout@v5 + + - name: Reference branch + id: ref-branch + uses: aidc-toolkit/.github/actions/ref-branch@main + + - name: Show branch + run: | + echo "branch=${{ steps.ref-branch.outputs.branch }}" + echo "branch_name=${{ steps.ref-branch.outputs.branch_name }}" diff --git a/.gitignore b/.gitignore index 6b9ae70..9a2f2e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /**/.DS_Store -/.npmrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac6ff0e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# GitHub Configuration + +This repository is used to configure GitHub for the AIDC Toolkit organization and to host stable actions for workflows. diff --git a/actions/ref-branch/action.yml b/actions/ref-branch/action.yml new file mode 100644 index 0000000..9efdbf3 --- /dev/null +++ b/actions/ref-branch/action.yml @@ -0,0 +1,51 @@ +name: Reference branch +description: Parse the GitHub context reference properties to determine the branch on which the workflow is running + +outputs: + branch: + description: Fully formed reference of the branch + value: ${{ steps.ref-branch.outputs.branch }} + branch_name: + description: Short reference name of the branch + value: ${{ steps.ref-branch.outputs.branch_name }} + +runs: + using: composite + + steps: + - name: Reference branch + id: ref-branch + shell: bash + run: | + if [[ "${{ github.ref_type }}" = "branch" ]] + then + # Reference is branch. + branch="${{ github.ref }}" + branch_name="${{ github.ref_name }}" + elif [[ "${{ github.ref_type }}" = "tag" ]] + then + # Tags are required to resolve the branch. + git fetch --tags + + branch_name=`git branch --remote --contains tags/${{ github.ref_name }} | cut -d '/' -f 2` + + branch_name_lines=`echo $branch_name | wc -l | xargs` + + # Tag must have a unique branch. + if [[ $branch_name_lines != 1 ]] + then + echo "Tag ${{ github.ref_name }} is not associated with a unique branch" + exit 1 + fi + + branch="refs/heads/$branch_name" + else + echo "Unsupported reference type ${{ github.ref_type }}" + exit 1 + fi + + echo "Branch is $branch" + echo "Branch name is $branch_name" + + echo "branch=$branch" >> $GITHUB_OUTPUT + echo "branch_name=$branch_name" >> $GITHUB_OUTPUT diff --git a/profile/README.md b/profile/README.md index 7a6c842..94819d1 100644 --- a/profile/README.md +++ b/profile/README.md @@ -1,5 +1,3 @@ # AIDC Toolkit -Welcome to the AIDC Toolkit, a comprehensive set of libraries for integrating Automatic Identification and Data Capture -(AIDC) functionality into web-based applications. To find out what it's all about, go to the -[documentation](https://aidc-toolkit.com) or explore the repositories. +Welcome to the AIDC Toolkit, a comprehensive set of libraries for integrating Automatic Identification and Data Capture (AIDC) functionality into web-based applications. To find out what it's all about, go to the [documentation](https://aidc-toolkit.com) or explore the repositories.