Skip to content

Commit

Permalink
feat: workflows back to brew and docker
Browse files Browse the repository at this point in the history
Signed-off-by: Devin Buhl <[email protected]>
  • Loading branch information
onedr0p committed Dec 31, 2024
1 parent 7863c99 commit 4016271
Showing 1 changed file with 25 additions and 72 deletions.
97 changes: 25 additions & 72 deletions .github/workflows/pre-pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,16 @@ env:
HOMEBREW_NO_ANALYTICS: "1"

jobs:
default-images:
name: Default Images
runs-on: ubuntu-latest
outputs:
images: ${{ steps.extract-images.outputs.images }}
steps:
- name: Generate Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Checkout
uses: actions/checkout@v4
with:
token: "${{ steps.app-token.outputs.token }}"
ref: "${{ github.event.repository.default_branch }}"

- name: Gather Images
uses: docker://ghcr.io/allenporter/flux-local:v7.0.0@sha256:abf237e31d20de26f8a4b08e588cc927cb0a9f0ecf90d04bada00f393b919354
with:
args: >-
get cluster
--path /github/workspace/kubernetes/main/flux
--enable-images
--output yaml
--output-file images.yaml
- name: Filter Images
shell: bash
run: |
yq -r '[.. | .images? | select(. != null)] | flatten | sort | unique | .[]' \
images.yaml > images.txt
- name: Extract Images
id: extract-images
shell: bash
run: |
images=$(jq --compact-output --raw-input --null-input '[inputs]' images.txt)
echo "images=${images}" >> $GITHUB_OUTPUT
pull-request-images:
name: Pull Request Images
extract-images:
name: Extract Images
runs-on: ubuntu-latest
strategy:
matrix:
branches: ["default", "pull"]
fail-fast: false
outputs:
images: ${{ steps.extract-images.outputs.images }}
default: ${{ steps.extract-images.outputs.default }}
pull: ${{ steps.extract-images.outputs.pull }}
steps:
- name: Generate Token
uses: actions/create-github-app-token@v1
Expand All @@ -77,9 +40,10 @@ jobs:
uses: actions/checkout@v4
with:
token: "${{ steps.app-token.outputs.token }}"
ref: "${{ matrix.branches == 'default' && github.event.repository.default_branch || '' }}"

- name: Gather Images
uses: docker://ghcr.io/allenporter/flux-local:v7.0.0@sha256:abf237e31d20de26f8a4b08e588cc927cb0a9f0ecf90d04bada00f393b919354
uses: docker://ghcr.io/allenporter/flux-local:v7.0.0
with:
args: >-
get cluster
Expand All @@ -88,55 +52,44 @@ jobs:
--output yaml
--output-file images.yaml
- name: Filter Images
shell: bash
run: |
yq -r '[.. | .images? | select(. != null)] | flatten | sort | unique | .[]' \
images.yaml > images.txt
- name: Extract Images
id: extract-images
shell: bash
run: |
images=$(jq --compact-output --raw-input --null-input '[inputs]' images.txt)
echo "images=${images}" >> $GITHUB_OUTPUT
images=$(yq --indent=0 --output-format=json \
'[.. | .images? | select(. != null)] | flatten | sort | unique' images.yaml \
)
echo "${{ matrix.branches }}=${images}" >> $GITHUB_OUTPUT
extract-images:
name: Extract Images
compare-images:
name: Compare Images
runs-on: ubuntu-latest
needs: ["default-images", "pull-request-images"]
needs: ["extract-images"]
outputs:
matrix: ${{ steps.extract-images.outputs.images }}
images: ${{ steps.compare-images.outputs.images }}
steps:
- name: Compare Default and Pull Request Images
id: extract-images
- name: Compare Images
id: compare-images
shell: bash
run: |
images=$(jq --compact-output --null-input \
--argjson f1 '${{ needs.default-images.outputs.images }}' \
--argjson f2 '${{ needs.pull-request-images.outputs.images }}' \
--argjson f1 '${{ needs.extract-images.outputs.default }}' \
--argjson f2 '${{ needs.extract-images.outputs.pull }}' \
'$f2 - $f1' \
)
echo "images=${images}" >> $GITHUB_OUTPUT
pre-pull-images:
if: ${{ needs.extract-images.outputs.matrix != '[]' && fromJSON(needs.extract-images.outputs.matrix).length <= 8 }}
if: ${{ needs.compare-images.outputs.images != '[]' }}
name: Pre-pull Images
runs-on: ["gha-runner-scale-set"]
needs: ["extract-images"]
needs: ["compare-images"]
strategy:
matrix:
images: ${{ fromJSON(needs.extract-images.outputs.matrix) }}
images: ${{ fromJSON(needs.compare-images.outputs.images) }}
max-parallel: 4
fail-fast: false
steps:
- name: Generate Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"

- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

Expand Down

0 comments on commit 4016271

Please sign in to comment.