From 0ae522a43e61c584f17e143560498c71aa345108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Budnik?= Date: Fri, 20 Aug 2021 14:12:34 +0200 Subject: [PATCH] changes to docker pipelines (autobuilds disabled on Docker Hub) --- .github/workflows/docker-image.yml | 14 +++----- .github/workflows/docker-publish.yml | 52 ++++++++++++++++++++++++++++ .github/workflows/go.yml | 25 ++++++------- go.mod | 2 +- 4 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8777189..7dad7b6 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,18 +1,12 @@ name: Docker Image CI -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] +on: [push, pull_request] jobs: - build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag yosoy-local:$(date +%s) + - uses: actions/checkout@v2.3.4 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag yosoy-local:$(date +%s) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..cd49cfe --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,52 @@ +name: Publish Docker image + +on: + push: + branches: [main] + release: + types: [published] + +jobs: + push_to_registries: + name: Push Docker image to Docker Hub and ghcr.io registries + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: | + lukasz/yosoy + ghcr.io/${{ github.repository }} + tags: | + type=raw,value=latest + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build and push Docker images + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 4047a0f..c595ff9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,25 +1,20 @@ name: Go -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] +on: [push, pull_request] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2.3.4 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.15 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 - - name: Build - run: go build -v ./... + - name: Build + run: go build -v ./... - - name: Test - run: go test -v ./... + - name: Test + run: go test -v ./... diff --git a/go.mod b/go.mod index 7bb8178..ab29064 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/lukaszbudnik/yosoy -go 1.15 +go 1.16 require ( github.com/gorilla/handlers v1.5.1