Skip to content

Commit

Permalink
CI from forks
Browse files Browse the repository at this point in the history
Signed-off-by: Mike McKiernan <[email protected]>
  • Loading branch information
mikemckiernan committed Apr 5, 2024
1 parent 95a125f commit da60f88
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/docs-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
outputs:
changed: ${{ steps.change.outputs.changed }}
image: ${{ steps.change.outputs.image }}
Expand All @@ -40,14 +41,24 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Manifest
shell: bash
run: |
docker manifest inspect "${REGISTRY}/${IMAGE_NAME,,}:${TAG}"
- name: Detect change
id: change
shell: bash
run: |
export COMMIT_SHORT_SHA="${GITHUB_SHA:0:8}"
if ! docker manifest inspect "${REGISTRY}/${IMAGE_NAME}:${TAG}" 2>&1 > /dev/null ; then export NEEDS_IMAGE=true ; fi
docker manifest inspect "${REGISTRY}/${IMAGE_NAME,,}:${TAG}"
if ! docker manifest inspect "${REGISTRY}/${IMAGE_NAME,,}:${TAG}" 2>&1 > /dev/null ; then
echo "image not found...${REGISTRY}/${IMAGE_NAME,,}:${TAG}"
export NEEDS_IMAGE=true
fi
def_branch=$(gh api "repos/${GITHUB_REPOSITORY}" -q '.default_branch')
git fetch origin "${def_branch}"
files=$(git diff --name-only "${GITHUB_SHA}" "origin/${def_branch}" | tr '\n' ' ')
echo "${files}"
if echo "${files}" | grep -q "deps/\|Dockerfile\|repo.toml"; then export NEEDS_IMAGE=true ; fi
if [[ "${NEEDS_IMAGE}" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
Expand All @@ -60,7 +71,6 @@ jobs:
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "image=${REGISTRY}/${IMAGE_NAME,,}:${TAG}" >> "$GITHUB_OUTPUT"
fi
shell: bash
build-and-push-image:
needs: dockerfile-changed
Expand Down

0 comments on commit da60f88

Please sign in to comment.