Skip to content

Update all code πŸ™ 5 #78

Update all code πŸ™ 5

Update all code πŸ™ 5 #78

Workflow file for this run

name: GitHub CI
on:
workflow_dispatch:
# pull_request:
push:
# schedule:
# - cron: 0 0 * * 0
defaults:
run:
shell: 'bash -Eeuo pipefail -x {0}'
env:
GAR_LOCATION: europe-west1 # GAR google artifact registry
# DOCKER_BUILDKIT: 1
jobs:
generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
image_name: ${{ steps.generate-jobs.outputs.image_name }}
steps:
- uses: actions/checkout@v4
# - uses: docker-library/bashbrew@HEAD
- uses: docker-library/bashbrew@HEAD
# - id: auth
# uses: 'google-github-actions/auth@v2'
# with:
# token_format: 'access_token'
# workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
# service_account: ${{ secrets.SERVICE_ACCOUNT }}
- id: generate-jobs
name: Generate Jobs
run: |
strategy="$("$BASHBREW_SCRIPTS/github-actions/generate.sh")"
# https://github.com/docker-library/python/pull/706 (ensure we don't have any unexpected ".a" leftovers in "/usr/local")
strategy="$(jq <<<"$strategy" -c '
.matrix.include |= map(
if .os == "ubuntu-latest" then
.runs.test += "\n" + (
.meta.entries
| map(
.tags[0]
| "aFiles=\"$(docker run --rm \(. | @sh) find /usr/local -name \"*.a\" | tee /dev/stderr)\"; [ -z \"$aFiles\" ]"
)
| join("\n")
)
else . end
)
')"
# echo -------------------debug------------------------------------
# jq . <<<"$strategy" # sanity check / debugging aid
# echo -------------------end debug--------------------------------
#### custom code to replace image name in generated workflow code ###
# replace image name in generated workflow code
matrix_names="$(jq <<<"$strategy" -rc '.matrix.include | map(.name) | join(" ")')"
IMAGE_NAME='ghcr.io/bluecodecom/python'
echo "$IMAGE_NAME"
for name in $matrix_names; do
echo Updating "$name" ...
strategy="$(jq <<< "$strategy" -c '
def replace_namespace:
gsub("python";"'"$IMAGE_NAME"'");
.matrix.include |= map(
(
select(.name == "'"$name"'") | .runs
) += {
"namespace_tags": .runs.build | replace_namespace
}
)
')"
done
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
#### end custom code ###############################################
EOF="EOF-$RANDOM-$RANDOM-$RANDOM"
echo "strategy<<$EOF" >> "$GITHUB_OUTPUT"
jq <<<"$strategy" . | tee -a "$GITHUB_OUTPUT" # debug and write to output
echo "$EOF" >> "$GITHUB_OUTPUT"
test-and-push:
needs: generate-jobs
permissions:
contents: read
packages: write
attestations: write
id-token: write
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Prepare Environment
run: ${{ matrix.runs.prepare }}
- name: Pull Dependencies
run: ${{ matrix.runs.pull }}
- name: Build ${{ matrix.name }}
run: ${{ matrix.runs.build }}
- name: History ${{ matrix.name }}
run: ${{ matrix.runs.history }}
- name: Test ${{ matrix.name }}
run: ${{ matrix.runs.test }}
- name: '"docker images"'
run: ${{ matrix.runs.images }}
#### Custom section ####
- name: 'build_namespace_tags'
run: ${{ matrix.runs.namespace_tags }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "set tags to push"
id: tags_to_push
run: |
IMAGE_NAME="${{ needs.generate-jobs.outputs.image_name }}"
docker push "$IMAGE_NAME" --all-tags
#### end of custom section ####