Skip to content

Commit d5ebf5d

Browse files
committed
github: add deployment workflow
1 parent b9ccbd3 commit d5ebf5d

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/workflows/master.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v2
23-
- name: Set Release Version
24-
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/}
25-
- name: Test
23+
- name: Set release version
24+
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/*/v}
25+
- name: Build Docker image
2626
run: |
27-
echo $RELEASE_VERSION
28-
echo ${{ env.RELEASE_VERSION }}
27+
make docker-image TAG=${{ env.RELEASE_VERSION }} GTAG=${{ secrets.GTAG }}
28+
- name: Deploy image to Docker hub
29+
run: |
30+
make docker-push-image TAG=${{ env.RELEASE_VERSION }} \
31+
DOCKER_USER=${{ secrets.DOCKER_USER }} \
32+
DOCKER_PASS=${{ secrets.DOCKER_PASS }}

docker.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ DOCKERFILE ?= ./build/Dockerfile
22
IMG_NAME ?= x1unix/go-playground
33

44
.PHONY: docker
5-
docker: docker-login docker-image
5+
docker: docker-image docker-push-image
6+
@echo "[✓] Done"
7+
8+
.PHONY: docker-push-image
9+
docker-push-image: docker-login
10+
@if [ -z "$(TAG)" ]; then\
11+
echo "required parameter TAG is undefined" && exit 1; \
12+
fi;
613
@echo "- Pushing $(IMG_NAME):$(TAG) (as latest)..."
714
docker push $(IMG_NAME):$(TAG)
815
docker push $(IMG_NAME):latest

0 commit comments

Comments
 (0)