-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Docker | ||
on: | ||
push: | ||
tags: ['v*'] | ||
branches: ['master'] | ||
pull_request: | ||
release: | ||
types: ['published'] | ||
|
||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build the Docker image | ||
run: docker build . --file Dockerfile | ||
|
||
docker-push: | ||
name: "Push to Registries" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build the container image | ||
uses: docker/build-push-action@v1 | ||
with: | ||
repository: golang-repo-template | ||
|
||
- name: Push to GitHub Packages | ||
uses: docker/build-push-action@v1 | ||
if: github.event_name == 'release' | ||
with: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
registry: docker.pkg.github.com | ||
repository: moul/golang-repo-template/golang-repo-template | ||
tag_with_ref: true | ||
|
||
- name: Check Docker Hub Credentials | ||
id: check_dockerhub_credentials | ||
if: github.event_name == 'release' | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
if [ "${DOCKER_USERNAME}" == "" ]; then | ||
echo "Missing Username" | ||
echo "##[set-output name=missingsecrets;]$(echo yes)" | ||
elif [ "${DOCKER_PASSWORD}" == "" ]; then | ||
echo "Missing Password" | ||
echo "##[set-output name=missingsecrets;]$(echo yes)" | ||
else | ||
echo "All secrets present" | ||
echo "##[set-output name=missingsecrets;]$(echo no)" | ||
fi | ||
- name: Push to Docker Hub | ||
if: | | ||
github.event_name == 'release' && | ||
contains(steps.check_dockerhub_credentials.outputs.missingsecrets, 'no') | ||
uses: docker/build-push-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
repository: moul/golang-repo-template | ||
tag_with_ref: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters