mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
github: setup github workflow to publish to DockerHub
This workflow tags and publishes images to Dockerhub: * Every `push` to `master` branch * Every release For successful workflow runs the following secrets need to be set in the repository `Secrets` section: * `DOCKERHUB_USERNAME` - the username to publish images to DockerHub * `DOCKERHUB_PASSWORD` - the password of `DOCKERHUB_USERNAME`
This commit is contained in:
parent
81ea4bbfcf
commit
7dfdbcd456
1 changed files with 89 additions and 0 deletions
89
.github/workflows/publish_to_dockerhub.yml
vendored
Normal file
89
.github/workflows/publish_to_dockerhub.yml
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
name: Push images to DockerHub
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
push:
|
||||
# Publish `master` as Docker `latest` and `git_revision` images.
|
||||
branches:
|
||||
- master
|
||||
release:
|
||||
# Publish released commit as Docker `latest` and `git_revision` images.
|
||||
types:
|
||||
- published
|
||||
|
||||
# Allows to run this workflow manually from the Actions tab.
|
||||
workflow_dispatch:
|
||||
|
||||
# Environment variables.
|
||||
env:
|
||||
GO111MODULE: "on"
|
||||
|
||||
# A workflow run.
|
||||
jobs:
|
||||
test:
|
||||
name: Run tests before publishing
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Sync VM submodule
|
||||
run: |
|
||||
git submodule sync
|
||||
git submodule update --init
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15
|
||||
|
||||
- name: Restore go modules from cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /go/pkg/mod
|
||||
key: deps-${{ hashFiles('go.sum') }}
|
||||
|
||||
- name: Update Go modules
|
||||
run: go mod download
|
||||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
publish:
|
||||
# Ensure test job passes before pushing image.
|
||||
needs: test
|
||||
name: Publish image to DockerHub
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# Allows to fetch all history for all branches and tags. Need this for proper versioning.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15
|
||||
|
||||
- name: Restore go modules from cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /go/pkg/mod
|
||||
key: deps-${{ hashFiles('go.sum') }}
|
||||
|
||||
- name: Update Go modules
|
||||
run: go mod download
|
||||
|
||||
- name: Build images
|
||||
run: make image
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Push images to registry
|
||||
run: make image-push
|
Loading…
Reference in a new issue