Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-ni committed Jul 14, 2024
1 parent 5bcb080 commit 07f6e48
Showing 1 changed file with 24 additions and 38 deletions.
62 changes: 24 additions & 38 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
name: Build Docker Images
on: [push]
name: Build and Push

jobs:
build-docker-image:
strategy:
matrix:
target-cpu: ["znver3", "znver2", "skylake", "haswell", "sandybridge", "x86-64"]
on:
push:
branches:
- main

name: Build for ${{ matrix.target-cpu }}
env:
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_TARGET_ACCOUNT: ${{ secrets.DOCKERHUB_TARGET }}
permissions:
contents: read
packages: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v2
if: env.DOCKER_USERNAME
- id: metadata
uses: docker/metadata-action@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
images: ghcr.io/${{ github.repository }}
flavor: latest=true

- name: Login to ghcr
uses: docker/login-action@v2
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Convert GITHUB_REPOSITORY into lowercase
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Build Docker Image
run: |
docker build -t gateway-proxy:${{ matrix.target-cpu }} --build-arg TARGET_CPU=${{ matrix.target-cpu }} .
- name: Create manifest and push it
if: env.DOCKER_USERNAME && github.ref == 'refs/heads/main'
run: |
docker tag gateway-proxy:${{ matrix.target-cpu }} ${{ secrets.DOCKERHUB_TARGET }}/gateway-proxy:${{ matrix.target-cpu }}
docker push ${{ secrets.DOCKERHUB_TARGET }}/gateway-proxy:${{ matrix.target-cpu }}
docker tag gateway-proxy:${{ matrix.target-cpu }} ghcr.io/${REPO}:${{ matrix.target-cpu }}
docker push ghcr.io/${REPO}:${{ matrix.target-cpu }}
- uses: docker/build-push-action@v6
with:
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true

0 comments on commit 07f6e48

Please sign in to comment.