mirror of
https://github.com/datahub-project/datahub.git
synced 2025-06-27 05:03:31 +00:00
fix(ci): handle missing github ref (#13714)
This commit is contained in:
parent
ab5b08e725
commit
289abb6463
38
.github/scripts/docker_helpers.sh
vendored
38
.github/scripts/docker_helpers.sh
vendored
@ -1,6 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "GITHUB_REF: $GITHUB_REF"
|
||||
REF="${GITHUB_REF:-${GITHUB_REF_FALLBACK:-}}"
|
||||
if [ -z "$REF" ]; then
|
||||
echo "Error: No ref available from GITHUB_REF or fallback"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "GITHUB_REF: $REF"
|
||||
echo "GITHUB_SHA: $GITHUB_SHA"
|
||||
|
||||
export MAIN_BRANCH="master"
|
||||
@ -14,19 +20,19 @@ export SHORT_SHA=$(get_short_sha)
|
||||
echo "SHORT_SHA: $SHORT_SHA"
|
||||
|
||||
function get_tag {
|
||||
echo $(echo ${GITHUB_REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${MAIN_BRANCH_TAG},g" -e 's,refs/tags/,,g' -e 's,refs/heads/,,g' -e 's,refs/heads/,,g' -e 's,refs/pull/\([0-9]*\).*,pr\1,g' -e 's,/,-,g')
|
||||
echo $(echo ${REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${MAIN_BRANCH_TAG},g" -e 's,refs/tags/,,g' -e 's,refs/heads/,,g' -e 's,refs/heads/,,g' -e 's,refs/pull/\([0-9]*\).*,pr\1,g' -e 's,/,-,g')
|
||||
}
|
||||
|
||||
function get_tag_slim {
|
||||
echo $(echo ${GITHUB_REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${MAIN_BRANCH_TAG}-slim,g" -e 's,refs/tags/\(.*\),\1-slim,g' -e 's,refs/heads/\(.*\),\1-slim,g' -e 's,refs/heads/\(.*\),\1-slim,g' -e 's,refs/pull/\([0-9]*\).*,pr\1-slim,g' -e 's,/,-,g')
|
||||
echo $(echo ${REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${MAIN_BRANCH_TAG}-slim,g" -e 's,refs/tags/\(.*\),\1-slim,g' -e 's,refs/heads/\(.*\),\1-slim,g' -e 's,refs/heads/\(.*\),\1-slim,g' -e 's,refs/pull/\([0-9]*\).*,pr\1-slim,g' -e 's,/,-,g')
|
||||
}
|
||||
|
||||
function get_tag_full {
|
||||
echo $(echo ${GITHUB_REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${MAIN_BRANCH_TAG}-full,g" -e 's,refs/tags/\(.*\),\1-full,g' -e 's,refs/heads/\(.*\),\1-full,g' -e 's,refs/heads/\(.*\),\1-full,g' -e 's,refs/pull/\([0-9]*\).*,pr\1-full,g' -e 's,/,-,g')
|
||||
echo $(echo ${REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${MAIN_BRANCH_TAG}-full,g" -e 's,refs/tags/\(.*\),\1-full,g' -e 's,refs/heads/\(.*\),\1-full,g' -e 's,refs/heads/\(.*\),\1-full,g' -e 's,refs/pull/\([0-9]*\).*,pr\1-full,g' -e 's,/,-,g')
|
||||
}
|
||||
|
||||
function get_python_docker_release_v() {
|
||||
echo "$(echo "${GITHUB_REF}" | \
|
||||
echo "$(echo "${REF}" | \
|
||||
sed -e "s,refs/heads/${MAIN_BRANCH},1\!0.0.0+docker.${SHORT_SHA},g" \
|
||||
-e 's,refs/heads/\(.*\),1!0.0.0+docker.\1,g' \
|
||||
-e 's,refs/heads/\(.*\),1!0.0.0+docker.\1,g' \
|
||||
@ -37,12 +43,12 @@ function get_python_docker_release_v() {
|
||||
}
|
||||
# To run these, set TEST_DOCKER_HELPERS=1 and then copy the function + test cases into a bash shell.
|
||||
if [ ${TEST_DOCKER_HELPERS:-0} -eq 1 ]; then
|
||||
GITHUB_REF="refs/pull/4788/merge" get_python_docker_release_v # '1!0.0.0+docker.pr4788'
|
||||
GITHUB_REF="refs/tags/v0.1.2-test" get_python_docker_release_v # '0.1.2'
|
||||
GITHUB_REF="refs/tags/v0.1.2.1-test" get_python_docker_release_v # '0.1.2.1'
|
||||
GITHUB_REF="refs/tags/v0.1.2rc1-test" get_python_docker_release_v # '0.1.2rc1'
|
||||
GITHUB_REF="refs/heads/branch-name" get_python_docker_release_v # '1!0.0.0+docker.branch-name'
|
||||
GITHUB_REF="refs/heads/releases/branch-name" get_python_docker_release_v # 1!0.0.0+docker.releases-branch-name'
|
||||
REF="refs/pull/4788/merge" get_python_docker_release_v # '1!0.0.0+docker.pr4788'
|
||||
REF="refs/tags/v0.1.2-test" get_python_docker_release_v # '0.1.2'
|
||||
REF="refs/tags/v0.1.2.1-test" get_python_docker_release_v # '0.1.2.1'
|
||||
REF="refs/tags/v0.1.2rc1-test" get_python_docker_release_v # '0.1.2rc1'
|
||||
REF="refs/heads/branch-name" get_python_docker_release_v # '1!0.0.0+docker.branch-name'
|
||||
REF="refs/heads/releases/branch-name" get_python_docker_release_v # 1!0.0.0+docker.releases-branch-name'
|
||||
|
||||
GITHUB_REF="refs/tags/v0.1.2rc1" get_tag # '0.1.2rc1'
|
||||
GITHUB_REF="refs/tags/v0.1.2rc1" get_tag_slim # '0.1.2rc1-slim'
|
||||
@ -62,19 +68,19 @@ if [ ${TEST_DOCKER_HELPERS:-0} -eq 1 ]; then
|
||||
fi
|
||||
|
||||
function get_unique_tag {
|
||||
echo $(echo ${GITHUB_REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${SHORT_SHA},g" -e 's,refs/tags/,,g' -e "s,refs/heads/.*,${SHORT_SHA},g" -e 's,refs/pull/\([0-9]*\).*,pr\1,g')
|
||||
echo $(echo ${REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${SHORT_SHA},g" -e 's,refs/tags/,,g' -e "s,refs/heads/.*,${SHORT_SHA},g" -e 's,refs/pull/\([0-9]*\).*,pr\1,g')
|
||||
}
|
||||
|
||||
function get_unique_tag_slim {
|
||||
echo $(echo ${GITHUB_REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${SHORT_SHA}-slim,g" -e 's,refs/tags/\(.*\),\1-slim,g' -e "s,refs/heads/.*,${SHORT_SHA}-slim,g" -e 's,refs/pull/\([0-9]*\).*,pr\1-slim,g')
|
||||
echo $(echo ${REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${SHORT_SHA}-slim,g" -e 's,refs/tags/\(.*\),\1-slim,g' -e "s,refs/heads/.*,${SHORT_SHA}-slim,g" -e 's,refs/pull/\([0-9]*\).*,pr\1-slim,g')
|
||||
}
|
||||
|
||||
function get_unique_tag_full {
|
||||
echo $(echo ${GITHUB_REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${SHORT_SHA}-full,g" -e 's,refs/tags/\(.*\),\1-full,g' -e "s,refs/heads/.*,${SHORT_SHA}-full,g" -e 's,refs/pull/\([0-9]*\).*,pr\1-full,g')
|
||||
echo $(echo ${REF} | sed -e "s,refs/heads/${MAIN_BRANCH},${SHORT_SHA}-full,g" -e 's,refs/tags/\(.*\),\1-full,g' -e "s,refs/heads/.*,${SHORT_SHA}-full,g" -e 's,refs/pull/\([0-9]*\).*,pr\1-full,g')
|
||||
}
|
||||
|
||||
function get_platforms_based_on_branch {
|
||||
if [ "${{ github.event_name }}" == 'push' && "${{ github.ref }}" == "refs/heads/${MAIN_BRANCH}" ]; then
|
||||
if [ "${GITHUB_EVENT_NAME}" == "push" ] && [ "${REF}" == "refs/heads/${MAIN_BRANCH}" ]; then
|
||||
echo "linux/amd64,linux/arm64"
|
||||
else
|
||||
echo "linux/amd64"
|
||||
@ -90,6 +96,6 @@ function echo_tags {
|
||||
echo "unique_slim_tag=$(get_unique_tag_slim)"
|
||||
echo "unique_full_tag=$(get_unique_tag_full)"
|
||||
echo "python_release_version=$(get_python_docker_release_v)"
|
||||
echo "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
|
||||
echo "branch_name=${GITHUB_HEAD_REF:-${REF#refs/heads/}}"
|
||||
echo "repository_name=${GITHUB_REPOSITORY#*/}"
|
||||
}
|
||||
|
3
.github/workflows/docker-ingestion-smoke.yml
vendored
3
.github/workflows/docker-ingestion-smoke.yml
vendored
@ -28,6 +28,9 @@ jobs:
|
||||
uses: acryldata/sane-checkout-action@v3
|
||||
- name: Compute Tag
|
||||
id: tag
|
||||
env:
|
||||
GITHUB_REF_FALLBACK: ${{ github.ref }}
|
||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
||||
run: |
|
||||
source .github/scripts/docker_helpers.sh
|
||||
echo "tag=$(get_tag)" >> $GITHUB_OUTPUT
|
||||
|
3
.github/workflows/docker-unified.yml
vendored
3
.github/workflows/docker-unified.yml
vendored
@ -76,6 +76,9 @@ jobs:
|
||||
uses: acryldata/sane-checkout-action@v3
|
||||
- name: Compute Tag
|
||||
id: tag
|
||||
env:
|
||||
GITHUB_REF_FALLBACK: ${{ github.event_name == 'release' && format('refs/tags/{0}', github.event.release.tag_name) || github.ref}}
|
||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
||||
run: |
|
||||
source .github/scripts/docker_helpers.sh
|
||||
{
|
||||
|
3
.github/workflows/publish-datahub-jars.yml
vendored
3
.github/workflows/publish-datahub-jars.yml
vendored
@ -39,6 +39,9 @@ jobs:
|
||||
uses: acryldata/sane-checkout-action@v3
|
||||
- name: Compute Tag
|
||||
id: tag
|
||||
env:
|
||||
GITHUB_REF_FALLBACK: ${{ github.ref }}
|
||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
||||
run: |
|
||||
source .github/scripts/docker_helpers.sh
|
||||
TAG=$(echo ${GITHUB_REF} | sed -e 's,refs/tags/v,,g')
|
||||
|
Loading…
x
Reference in New Issue
Block a user