Skip to content

Commit

Permalink
ci: rewritten the image building action
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Urbanek <[email protected]>
  • Loading branch information
shanduur committed Nov 15, 2024
1 parent 220793a commit 201e487
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
name: CI

on: [ push, pull_request ]

permissions:
contents: write
packages: write

jobs:
test:
name: Test
Expand Down Expand Up @@ -36,6 +42,7 @@ jobs:
with:
command: test
args: --verbose ${{ matrix.features }}

doc:
name: Build documentation
runs-on: ubuntu-latest
Expand All @@ -55,6 +62,7 @@ jobs:
with:
command: doc
args: --verbose

coverage:
name: Coverage
runs-on: ubuntu-latest
Expand All @@ -81,21 +89,34 @@ jobs:
with:
command: tarpaulin
args: --coveralls $TOKEN
dockerhub:
name: Docker build and push to Docker Hub

ghcr:
name: Docker build and push to GitHub Container Registry
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
if: ${{ !(startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')) }}
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v2
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-qemu-action@v3
- id: buildx
uses: docker/setup-buildx-action@v3
with:
context: .
push: 'true'
tags: clevercloud/sozu:${{ github.sha }}
platforms: linux/amd64,linux/arm64
- uses: docker/build-push-action@v6
with:
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.event.repository.owner.name }}/sozu:${{ github.ref_name }}
- name: Scan image using Grype
id: grype
uses: anchore/scan-action@v5
with:
image: ghcr.io/${{ github.event.repository.owner.name }}/sozu:${{ github.ref_name }}
output-format: table
...

0 comments on commit 201e487

Please sign in to comment.