Skip to content

Commit 9e106a9

Browse files
author
Vladimir Kotal
committed
make Github actions properties available as env variables
1 parent 1289717 commit 9e106a9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.github/workflows/docker.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ jobs:
99
- name: Checkout master branch
1010
uses: actions/checkout@v2
1111
- name: Build Docker image
12+
env:
13+
OPENGROK_REPO_SLUG: ${{ github.repository }}
14+
OPENGROK_PULL_REQUEST: ${{ github.head_ref }}
15+
OPENGROK_REF: ${{ github.ref }}
1216
run: ./dev/docker.sh

dev/docker.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ set -e
1515
API_URL="https://hub.docker.com/v2"
1616
IMAGE="opengrok/docker"
1717

18-
if [[ -n $TRAVIS_TAG ]]; then
19-
VERSION="$TRAVIS_TAG"
18+
if [[ -n $OPENGROK_REF && $OPENGROK_REF == refs/tags/* ]]; then
19+
OPENGROK_TAG=${OPENGROK_REF#"refs/tags/"}
20+
fi
21+
22+
if [[ -n $OPENGROK_TAG ]]; then
23+
VERSION="$OPENGROK_TAG"
2024
VERSION_SHORT=$( echo $VERSION | cut -d. -f1,2 )
2125
else
2226
VERSION="latest"
@@ -52,20 +56,20 @@ docker run -d $IMAGE
5256
docker ps -a
5357

5458
# Travis can only work on master since it needs encrypted variables.
55-
if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
59+
if [ "${OPENGROK_PULL_REQUEST}" != "false" ]; then
5660
echo "Not pushing Docker image for pull requests"
5761
exit 0
5862
fi
5963

6064
# The push only works on the main repository.
61-
if [[ "${TRAVIS_REPO_SLUG}" != "oracle/opengrok" ]]; then
65+
if [[ "${OPENGROK_REPO_SLUG}" != "oracle/opengrok" ]]; then
6266
echo "Not pushing Docker image for non main repository"
6367
exit 0
6468
fi
6569

6670
# Allow Docker push for release builds only.
67-
if [[ -z $TRAVIS_TAG ]]; then
68-
echo "TRAVIS_TAG is empty"
71+
if [[ -z $OPENGROK_TAG ]]; then
72+
echo "OPENGROK_TAG is empty"
6973
exit 0
7074
fi
7175

0 commit comments

Comments
 (0)