Skip to content

Bump docker/login-action from 2 to 3 (#45) #47

Bump docker/login-action from 2 to 3 (#45)

Bump docker/login-action from 2 to 3 (#45) #47

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Build
on:
push:
branches: [ "main" ]
tags: [ '*.*.*' ]
pull_request:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
cache: true
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=semver,pattern={{version}},event=tag
- name: Build Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
load: ${{ github.event_name == 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: K3s test
# run: |
# curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION="v1.25.5+k3s1" K3S_KUBECONFIG_MODE=644 INSTALL_K3S_EXEC="server --docker --disable traefik" sh -
# mkdir -p ~/.kube
# cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
# chmod 600 ~/.kube/config
# make install
# make deploy IMG=$(echo $DOCKER_METADATA_OUTPUT_JSON | jq -r .tags[0])
# make test USE_EXISTING_CLUSTER=true
#
#
# - name: Generate release artifacts
# if: startsWith(github.ref, 'refs/tags/')
# run: |
# kubectl kustomize config/default >cluster-ip-operator.yaml
# curl -Lo kyma https://storage.googleapis.com/kyma-cli-unstable/kyma-linux
# chmod +x kyma
# ./kyma alpha create module -n kyma-project.io/cluster-ip --version $GITHUB_REF_NAME \
# --registry ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-module \
# -o cluster-ip-module-template.yaml -v
#
# - name: Setup tmate session
# if: failure()
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
#
# - name: Release
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# files: |
# cluster-ip-operator.yaml
# cluster-ip-module-template.yaml
#