Skip to content

Commit

Permalink
Add initial "composite" action for installing Bashbrew
Browse files Browse the repository at this point in the history
(Also, fix a few minor bugs in `scripts/github-actions/generate.sh` and update the example appropriately)
  • Loading branch information
tianon committed Nov 16, 2022
1 parent b8eda2b commit b61472b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# steps:
# - ...
# - uses: docker-library/bashbrew
# - ...

name: 'Install Bashbrew'
description: 'Install the "bashbrew" tool in GITHUB_PATH'
runs:
using: 'composite'
steps:
- uses: actions/setup-go@v3
with:
go-version-file: '${{ github.action_path }}/go.mod'
- run: |
'${{ github.action_path }}/bashbrew.sh' --version > /dev/null
'${{ github.action_path }}/bin/bashbrew' --version
echo '${{ github.action_path }}/bin' >> "$GITHUB_PATH"
echo 'BASHBREW_SCRIPTS=${{ github.action_path }}/scripts' >> "$GITHUB_ENV"
shell: 'bash -Eeuo pipefail -x {0}'
10 changes: 5 additions & 5 deletions scripts/github-actions/example-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ jobs:
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: docker-library/bashbrew
- id: generate-jobs
name: Generate Jobs
run: |
git clone --depth 1 https://github.com/docker-library/bashbrew.git -b master ~/bashbrew
strategy="$(~/bashbrew/scripts/github-actions/generate.sh)"
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
echo "strategy=$strategy" >> "$GITHUB_OUTPUT"
jq . <<<"$strategy" # sanity check / debugging aid
echo "::set-output name=strategy::$strategy"
test:
needs: generate-jobs
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
Expand Down
8 changes: 6 additions & 2 deletions scripts/github-actions/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ for tag in $tags; do
'
)"

parent="$(bashbrew parents "$bashbrewImage" | tail -1)" # if there ever exists an image with TWO parents in the same repo, this will break :)
if [ -n "$parent" ]; then
if parent="$(bashbrew parents "$bashbrewImage" | grep "^${tag%%:*}:")" && [ -n "$parent" ]; then
if [ "$(wc -l <<<"$parent")" -ne 1 ]; then
echo >&2 "error: '$tag' has multiple parents in the same repository and this script can't handle that yet!"
echo >&2 "$parent"
exit 1
fi
parentBashbrewImage="${parent##*/}" # account for BASHBREW_NAMESPACE being set
parent="$(bashbrew list --uniq "$parentBashbrewImage")" # normalize
parentMeta="${metas["$parent"]}"
Expand Down

0 comments on commit b61472b

Please sign in to comment.