Login using token as described in https://docs.github.com/en/packages… #134
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
name: Docker Image | |
on: | |
push: | |
branches: [ '*' ] | |
env: | |
# Common versions | |
GO_VERSION: '1.18' | |
GOLANGCI_VERSION: 'v1.47.1' | |
DOCKER_BUILDX_VERSION: 'v0.8.2' | |
SB1_VERSION: "0.32-sb1-13" | |
jobs: | |
build-image: | |
permissions: | |
packages: write | |
contents: read | |
name: Push Docker image to GitHub Packages | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: all | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: ${{ env.DOCKER_BUILDX_VERSION }} | |
install: true | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Fetch History | |
run: git fetch --prune --unshallow | |
- name: Setup Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Find the Go Build Cache | |
id: go | |
run: echo "::set-output name=cache::$(make go.cachedir)" | |
- name: Cache the Go Build Cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.go.outputs.cache }} | |
key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-build-publish-artifacts- | |
- name: Cache Go Dependencies | |
uses: actions/cache@v2 | |
with: | |
path: .work/pkg | |
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-pkg- | |
- name: Vendor Dependencies | |
run: make vendor vendor.check | |
- name: Build Artifacts | |
run: make -j2 build.all | |
env: | |
# We're using docker buildx, which doesn't actually load the images it | |
# builds by default. Specifying --load does so. | |
BUILD_ARGS: "--load" | |
VERSION: ${{ env.SB1_VERSION }} | |
CHANNEL: "master" | |
DOCKER_REGISTRY: ghcr.io/sparebank1utvikling | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Disable arm64 | |
run: sed -i s,linux_arm64,, cluster/images/*/Makefile | |
- name: Promote Artifacts | |
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/} PLATFORMS=linux_amd64 | |
env: | |
VERSION: ${{ env.SB1_VERSION }} | |
CHANNEL: "master" | |
DOCKER_REGISTRY: ghcr.io/sparebank1utvikling | |
XPKG_REG_ORGS: ghcr.io/sparebank1utvikling |