Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): publish the staging Docker image with goreleaser #179

Merged
merged 1 commit into from
Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/publish-staging-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Push the staging Docker image (ghcr.italia/developers-italia-api:main)
# on updates to main.

on:
push:
branches: [ main ]

permissions:
# To push Docker images to GitHub
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
uses: actions/setup-go@v3
with:
go-version: 1.18.x
-
uses: actions/checkout@v2
with:
# All history, required for goreleaser
fetch-depth: 0
-
# FIXME: goreleaser should already take care of the login
# (see https://github.com/goreleaser/goreleaser/blame/02a3486d4ba59505113a57b438ae567351ed3dab/scripts/entrypoint.sh#L17)
# but it doesn't work for some reason.
run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u docker --password-stdin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

-
# Tag with a temporary valid semantic version. This is required by goreleaser.
run: git tag $(git describe --tags --abbrev=0)-main-$(git rev-parse --short HEAD)

-
uses: goreleaser/goreleaser-action@v2
with:
version: v1.9.2
args: release --config .goreleaser.staging.yaml
21 changes: 21 additions & 0 deletions .goreleaser.staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Goreleases configuration for staging builds, just builds and pushes
# the Docker image for the main branch.
#
# Make sure to check the documentation at https://goreleaser.com

# Don't create a GitHub release
release:
disable: true

builds:
- env:
- CGO_ENABLED=0
ldflags:
- -s -w
goos:
- linux
dockers:
-
dockerfile: Dockerfile.goreleaser
image_templates:
- "ghcr.io/italia/developers-italia-api:main"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This is for local development only.
# See Dockerfile.goreleaser for the image published on release.
# See Dockerfile.goreleaser for the image published on release or staging.
#

FROM golang:1.18 as base
Expand Down