Skip to content

Commit

Permalink
Merge pull request #130 from devilbox/github-actions
Browse files Browse the repository at this point in the history
Prepare push phase
  • Loading branch information
cytopia authored Nov 8, 2019
2 parents a0a0738 + 696faf5 commit 83f5743
Showing 1 changed file with 70 additions and 21 deletions.
91 changes: 70 additions & 21 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,35 @@ jobs:
- '7.4'
- '8.0'
steps:

# ------------------------------------------------------------
# Checkout repository
# ------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v1

- name: Set variables
id: vars
run: |
# Set git branch or git tag as slug
if [[ ${GITHUB_REF} =~ ^refs\/tags\/ ]]; then
GIT_TYPE=TAG
GIT_SLUG="${GITHUB_REF/refs\/tags\//}"
else
GIT_TYPE=BRANCH
if [ -n "${GITHUB_HEAD_REF}" ]; then
GIT_SLUG="${GITHUB_HEAD_REF}"
else
GIT_SLUG="${GITHUB_REF/refs\/heads\//}"
fi
fi
# Export variable
# # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#set-an-environment-variable-set-env
echo ::set-env name=GIT_TYPE::${GIT_TYPE}
echo ::set-env name=GIT_SLUG::${GIT_SLUG}
# ------------------------------------------------------------
# Base
# ------------------------------------------------------------
Expand All @@ -101,10 +127,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make build-base VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -118,10 +144,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make test-base VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -139,10 +165,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make build-mods VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -156,10 +182,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make test-mods VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -177,10 +203,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make build-prod VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -194,10 +220,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make test-prod VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -215,10 +241,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make build-work VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -232,10 +258,10 @@ jobs:
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
sleep 10
retry make test-work VERSION=${VERSION}
env:
VERSION: ${{ matrix.version }}
Expand All @@ -260,23 +286,46 @@ jobs:
# Only run this, if the PR was created by the repo owner
- name: Publish images (only repo owner)
run: |
# Set branch or tag as slug
if [[ ${GITHUB_REF} =~ ^refs\/tags\/ ]]; then
GIT_TYPE=TAG
GIT_SLUG="${GITHUB_REF/refs\/tags\//}"
else
GIT_TYPE=BRANCH
if [ -n "${GITHUB_HEAD_REF}" ]; then
GIT_SLUG="${GITHUB_HEAD_REF}"
else
GIT_SLUG="${GITHUB_REF/refs\/heads\//}"
fi
fi
retry() {
for ((n=0; n<${RETRIES}; n++)); do
echo "[${n}] ${*}";
if eval "${*}"; then
return 0;
fi;
sleep 10;
done;
return 1;
}
# Info output
echo "Git Type: ${GIT_TYPE}"
echo "Git Slug: ${GIT_SLUG}"
echo "Todo: Push to Dockerhub"
# Login
echo "retry make login USER= PASS="
# Push
if [ "${GIT_TYPE}" = "TAG" ]; then
echo "retry make push-base VERSION=${VERSION}-${GIT_SLUG}"
echo "retry make push-mods VERSION=${VERSION}-${GIT_SLUG}"
echo "retry make push-prod VERSION=${VERSION}-${GIT_SLUG}"
echo "retry make push-work VERSION=${VERSION}-${GIT_SLUG}"
else
if [ "${GIT_SLUG}" = "master" ]; then
echo "retry make push-base VERSION=${VERSION}"
echo "retry make push-mods VERSION=${VERSION}"
echo "retry make push-prod VERSION=${VERSION}"
echo "retry make push-work VERSION=${VERSION}"
else
echo "retry make push-base VERSION=${VERSION}-${GIT_SLUG}"
echo "retry make push-mods VERSION=${VERSION}-${GIT_SLUG}"
echo "retry make push-prod VERSION=${VERSION}-${GIT_SLUG}"
echo "retry make push-work VERSION=${VERSION}-${GIT_SLUG}"
fi
fi
env:
VERSION: ${{ matrix.version }}
RETRIES: 5
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#functions
if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
&& (
Expand Down

0 comments on commit 83f5743

Please sign in to comment.