github.com/quay/claircore@v1.5.28/.github/workflows/golang-image.yml (about)

     1  ---
     2  name: Build and publish golang image
     3  
     4  on:
     5    workflow_dispatch:
     6      inputs:
     7        force:
     8          description: 'Force a build and push'
     9          required: false
    10          type: boolean
    11          default: false
    12    # Run every day at 5AM UTC
    13    schedule:
    14      - cron: '0 5 * * *'
    15  
    16  env:
    17    QUAY_ORG: projectquay
    18    QUAY_REPO: golang
    19    QUAY_USER: projectquay+claircore_github
    20  
    21  jobs:
    22    golang-image:
    23      if: ${{ github.repository == 'quay/claircore' }}
    24      name: Build and publish golang image
    25      runs-on: 'ubuntu-latest'
    26      strategy:
    27        fail-fast: false
    28        matrix:
    29          go: ['1.18', '1.19', '1.20', '1.21', '1.22']
    30      steps:
    31        - name: Checkout
    32          uses: actions/checkout@v4
    33        - name: Check verisons and dates
    34          run: |
    35            v=$(.github/scripts/get-latest-golang-minor-version.sh ${{ matrix.go }})
    36            t=$(curl -sSLf "https://quay.io/api/v1/repository/${QUAY_ORG}/${QUAY_REPO}/tag/?specificTag=${{ matrix.go }}&onlyActiveTags=true" |
    37              jq -r '.tags[0].last_modified//"Thu, 01 Jan 1970 00:00:00 -0000"')
    38            g=$(curl -sSLfI --http2 "https://dl.google.com/go/go${v}.linux-amd64.tar.gz" |
    39              awk 'BEGIN {FS=": "}/^last-modified/{print $2}')
    40            cat <<.
    41            ::notice title=Latest Go version::$v
    42            ::notice title=Latest tag update::$t
    43            ::notice title=Go version update::$g
    44            .
    45            cat <<. >>"$GITHUB_ENV"
    46            GO_VERSION=$v
    47            TAG_LAST_MODIFIED=$t
    48            GO_LAST_MODIFIED=$g
    49            .
    50        - name: Decide whether we need to build new golang image
    51          run: |
    52            TAG=$(date -d "${TAG_LAST_MODIFIED}" +%s)
    53            GO=$(date -d "${GO_LAST_MODIFIED}" +%s)
    54            if test "${{ inputs.force }}" = 'true' -o "$GO" -gt "$TAG"; then
    55              echo "BUILD_IMAGE=1" >> "$GITHUB_ENV"
    56            fi
    57        - name: Set up QEMU
    58          if: env.BUILD_IMAGE == 1
    59          run: |
    60            sudo apt-get update
    61            sudo apt-get install -y qemu-user-static
    62        - name: Build
    63          uses: redhat-actions/buildah-build@v2
    64          if: env.BUILD_IMAGE == 1
    65          with:
    66            platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
    67            build-args: |
    68              GO_VERSION=${{ env.GO_VERSION }}
    69            containerfiles: etc/Dockerfile
    70            context: etc
    71            tags: |
    72              quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_REPO }}:${{ matrix.go }}
    73        - uses: redhat-actions/podman-login@v1
    74          if: env.BUILD_IMAGE == 1
    75          with:
    76            registry: quay.io
    77            username: ${{ env.QUAY_USER }}
    78            password: ${{ secrets.QUAY_TOKEN }}
    79        - name: Publish
    80          uses: redhat-actions/push-to-registry@v2
    81          if: env.BUILD_IMAGE == 1
    82          with:
    83            #extra-args: |
    84            #  --compression-format=zstd:chunked
    85            tags: |
    86              quay.io/${{ env.QUAY_ORG }}/${{ env.QUAY_REPO }}:${{ matrix.go }}