Skip to content

try xgo github action (#12) #39

try xgo github action (#12)

try xgo github action (#12) #39

name: Build and push latest image
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
TERM: xterm-color
REGISTRY: quay.io
jobs:
build-exe:
name: Build and push image
runs-on: ubuntu-22.04
env:
SHELL: /bin/bash
KUBECONFIG: '/home/runner/.kube/config'
steps:
- name: Set up go 1.22
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Disable default go problem matcher
run: echo "::remove-matcher owner=go::"
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Cross building images
uses: crazy-max/ghaction-xgo@v3
with:
xgo_version: latest
go_version: 1.22
dest: build
prefix: myapp
targets: linux/amd64,linux/arm64
v: true
x: false
race: false
ldflags: -s -w
buildmode: default
trimpath: true
- name: Authenticate against Quay.io
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'redhat-cne' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
# Use a Robot Account to authenticate against Quay.io
# https://docs.quay.io/glossary/robot-accounts.html
username: ${{ secrets.QUAY_ROBOT_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
- name: Build and push image
if: ${{ github.ref == 'refs/heads/main' && github.repository_owner == 'redhat-cne' }}
run: ./scripts/image.sh