Bump docker/login-action from 2.2.0 to 3.0.0 #717
Workflow file for this run
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 build and push | |
on: | |
pull_request: | |
types: [ closed ] | |
push: | |
branches: | |
- 'master' | |
jobs: | |
build-latest: | |
if: ${{ github.event.pull_request.merged == true || ( github.ref == 'refs/heads/master' && github.event_name == 'push' ) }} | |
name: Build latest Image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [amd64, arm64, 386] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare multiarch | |
run: sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
- name: Build latest image | |
id: build-latest-image | |
uses: redhat-actions/[email protected] | |
with: | |
image: loki | |
archs: ${{ matrix.arch }} | |
tags: latest-${{ matrix.arch }} | |
dockerfiles: | | |
./Dockerfile | |
build-args: | | |
VERSION=master | |
GOARCH=${{ matrix.arch }} | |
- name: Push latest image to ghcr | |
uses: redhat-actions/[email protected] | |
with: | |
image: ${{ steps.build-latest-image.outputs.image }} | |
tags: ${{ steps.build-latest-image.outputs.tags }} | |
registry: ghcr.io/${{ github.repository_owner }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
build-version: | |
if: ${{ github.event.pull_request.merged == true || ( github.ref == 'refs/heads/master' && github.event_name == 'push' ) }} | |
outputs: | |
version: ${{ steps.loki-version.outputs.version }} | |
name: Build Version Image | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [amd64, arm64, 386] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get latest Loki release | |
id: loki-version | |
run: | | |
export LOKI_LATEST=$(curl -s "https://api.github.com/repos/grafana/loki/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")') | |
echo "VERSION=$LOKI_LATEST" >> ${GITHUB_ENV} | |
echo "version=$LOKI_LATEST" >> ${GITHUB_OUTPUT} | |
shell: bash | |
- name: check if latest loki is already a package version | |
id: get_versions | |
uses: octokit/[email protected] | |
with: | |
route: GET /user/packages/container/loki/versions | |
env: | |
GITHUB_TOKEN: ${{ secrets.PACKAGES }} | |
- run: | | |
export LOKI_AVAIL=$(echo "${{ steps.get_versions.outputs.data }}"|grep -Po "${VERSION}"|head -1) | |
echo "AVAIL=$LOKI_AVAIL" >> ${GITHUB_ENV} | |
- name: Prepare multiarch | |
run: sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes | |
if: env.VERSION != env.AVAIL | |
- name: Build version image | |
id: build-version-image | |
uses: redhat-actions/[email protected] | |
with: | |
image: loki | |
archs: ${{ matrix.arch }} | |
tags: ${{ env.VERSION }}-${{ matrix.arch }} | |
dockerfiles: | | |
./Dockerfile | |
build-args: | | |
VERSION=${{ env.VERSION }} | |
GOARCH=${{ matrix.arch }} | |
if: env.VERSION != env.AVAIL | |
- name: Push version image to ghcr | |
uses: redhat-actions/[email protected] | |
with: | |
image: ${{ steps.build-version-image.outputs.image }} | |
tags: ${{ steps.build-version-image.outputs.tags }} | |
registry: ghcr.io/${{ github.repository_owner }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: env.VERSION != env.AVAIL | |
create-manifest-latest: | |
needs: build-latest | |
if: ${{ github.event.pull_request.merged == true || ( github.ref == 'refs/heads/master' && github.event_name == 'push' ) }} | |
name: Create manifest for latest image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: pull latest images | |
run: | | |
docker pull ghcr.io/${{ github.repository_owner }}/loki:latest-arm64 | |
docker pull ghcr.io/${{ github.repository_owner }}/loki:latest-amd64 | |
docker pull ghcr.io/${{ github.repository_owner }}/loki:latest-386 | |
- name: create latest manifest list | |
run: | | |
docker manifest create ghcr.io/${{ github.repository_owner }}/loki:latest ghcr.io/${{ github.repository_owner }}/loki:latest-arm64 ghcr.io/${{ github.repository_owner }}/loki:latest-amd64 ghcr.io/${{ github.repository_owner }}/loki:latest-386 | |
docker manifest annotate ghcr.io/${{ github.repository_owner }}/loki:latest ghcr.io/${{ github.repository_owner }}/loki:latest-arm64 --arch arm64 | |
docker manifest annotate ghcr.io/${{ github.repository_owner }}/loki:latest ghcr.io/${{ github.repository_owner }}/loki:latest-amd64 --arch amd64 | |
docker manifest annotate ghcr.io/${{ github.repository_owner }}/loki:latest ghcr.io/${{ github.repository_owner }}/loki:latest-386 --arch 386 | |
- name: push latest manifest | |
run: | | |
docker manifest push ghcr.io/${{ github.repository_owner }}/loki:latest | |
create-manifest-version: | |
needs: build-version | |
if: ${{ github.event.pull_request.merged == true || ( github.ref == 'refs/heads/master' && github.event_name == 'push' ) }} | |
name: Create manifest for version image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: pull version images | |
run: | | |
docker pull ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-arm64 | |
docker pull ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-amd64 | |
docker pull ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-386 | |
- name: create version manifest list | |
run: | | |
docker manifest create ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}} ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-arm64 ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-amd64 ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-386 | |
docker manifest annotate ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}} ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-arm64 --arch arm64 | |
docker manifest annotate ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}} ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-amd64 --arch amd64 | |
docker manifest annotate ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}} ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}}-386 --arch 386 | |
- name: push version manifest | |
run: | | |
docker manifest push ghcr.io/${{ github.repository_owner }}/loki:${{needs.build-version.outputs.version}} |