Skip to content

pass creds to testing ci #3

pass creds to testing ci

pass creds to testing ci #3

Workflow file for this run

name: Build and push images
on:
push:
branches-ignore: ['releases/**']
env:
REGISTRY: ghcr.io
jobs:
build-and-push-images:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in
# this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
outputs:
dir_changes: ${{ steps.directory-changes.outputs.changed_dirs }}
steps:
- name: Debug Event Payload
env:
EVENT_PAYLOAD: ${{ toJson(github.event) }}
run: echo "$EVENT_PAYLOAD"
- name: Checkout repository
uses: actions/checkout@v4
- name: Git branch name
id: git-branch-name
run: echo "${{ github.head_ref || github.ref_name }}"
- name: Directory Changes
id: directory-changes
run: |
case "${{ github.event_name }}" in
"pull_request")
base_ref="${GITHUB_BASE_REF}"
git fetch origin "${base_ref}"
changed_dirs="$(git --no-pager diff --name-only HEAD origin/${base_ref} | xargs -n1 dirname | sort -u)"
;;
"push")
git fetch origin "${{ github.event.before }}"
changed_dirs="$(git --no-pager diff-tree --name-only -r ${{ github.event.before }}..${{ github.event.after }} | xargs -n1 dirname | sort -u)"
;;
*)
changed_dirs="$(git ls-files | xargs -n1 dirname | sort -u)"
;;
esac
# keep only image directories
dirs=""
for dir in $changed_dirs; do
if [ -f $dir/Dockerfile ]; then
dirs="$dirs $dir"
fi
done
# save it in json format
changed_dirs=$(echo "$dirs" | jq -R -c 'gsub("\r\n";"") | split(" ") | map(select(length > 0))')
echo "++ changed_dirs: $changed_dirs"
echo "changed_dirs=$changed_dirs" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v5
id: setup_python
with:
python-version: '3.12'
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push images
id: push
env:
DIR_CHANGES: ${{ steps.directory-changes.outputs.changed_dirs }}
run: |
echo "DIR_CHANGES: $DIR_CHANGES"
python scripts/build.py --debug \
--registry "$REGISTRY" --repository "${{ github.repository }}" \
--tag "${{ github.head_ref || github.ref_name }}" \
--push $DIR_CHANGES
test-images:
needs: build-and-push-images
uses: ./.github/workflows/run-tests.yml
secrets: inherit
with:
# pass the images that changed for testing
images: ${{ needs.build-and-push-images.outputs.dir_changes }}