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 387accd
Showing 1 changed file with 23 additions and 37 deletions.
60 changes: 23 additions & 37 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 Image

jobs:
build-docker-image:
strategy:
matrix:
target-cpu: ["znver3", "znver2", "skylake", "haswell", "sandybridge", "x86-64"]
permissions:
packages: write

name: Build for ${{ matrix.target-cpu }}
env:
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_TARGET_ACCOUNT: ${{ secrets.DOCKERHUB_TARGET }}
on:
push:
pull_request:

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

- name: Login to DockerHub
uses: docker/login-action@v2
if: env.DOCKER_USERNAME
- id: metadata
uses: docker/metadata-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
images: ghcr.io/poketwo/gateway-proxy

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

- name: Convert GITHUB_REPOSITORY into lowercase
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
password: ${{ secrets.GHCR_PAT }}

- 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 }}
- uses: docker/build-push-action@v4
with:
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
secrets: |
GIT_AUTH_TOKEN=${{ secrets.GHCR_PAT }}
docker tag gateway-proxy:${{ matrix.target-cpu }} ghcr.io/${REPO}:${{ matrix.target-cpu }}
docker push ghcr.io/${REPO}:${{ matrix.target-cpu }}

0 comments on commit 387accd

Please sign in to comment.