From 2a9d1d267931b75b0854645329c334554e2e5cb1 Mon Sep 17 00:00:00 2001 From: Emmanuel Gautier Date: Tue, 12 Mar 2024 15:19:39 +0100 Subject: [PATCH] ci: build and push docker images --- .github/workflows/ci.yml | 55 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e52a38b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + list-examples: + runs-on: ubuntu-latest + + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + + steps: + - uses: actions/checkout@v4 + + - id: set-matrix + run: echo "matrix=$(ls examples/ | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + + docker-build-push: + needs: list-examples + runs-on: ubuntu-latest + + permissions: + packages: write + + strategy: + matrix: + example: ${{ fromJson(needs.list-examples.outputs.matrix) }} + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./examples/${{ matrix.example }} + push: ${{ github.ref == 'refs/heads/main' }} + tags: ghcr.io/cerberauth/openid-connect-examples/${{ matrix.example }}:latest + cache-from: type=registry,ref=ghcr.io/cerberauth/openid-connect-examples/${{ matrix.example }}:latest + cache-to: type=inline