From 07ab49c873b5ba81ba5c01d77e35f1bf5169a392 Mon Sep 17 00:00:00 2001 From: John Long Date: Thu, 4 Aug 2022 14:35:36 -0400 Subject: [PATCH] feat: using GHCR as the new registry (#4) This patch implements the use of ghcr.io as the new container registry for the project. Signed-off-by: Jonathan Gonzalez V Co-authored-by: Jonathan Gonzalez V --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++---------- Dockerfile | 1 + 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d02afba..d20ceb0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,34 +5,55 @@ on: branches: [ main ] tags: [ '*' ] workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}, + jobs: build: + permissions: + contents: read + packages: write runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout source code + uses: actions/checkout@v3.0.2 - name: Get the reference id: get_version run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + - name: Image metadata + id: metadata + uses: docker/metadata-action@v3.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version} + - name: Set up QEMU uses: docker/setup-qemu-action@v2.0.0 with: - image: tonistiigi/binfmt:qemu-v6.1.0 + image: tonistiigi/binfmt:qemu-v6.2.0 platforms: "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x" - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2.0.0 + - name: Login to registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: - registry: quay.io - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v3.0.0 + uses: docker/build-push-action@v3.1.0 with: + context: . platforms: "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x" - tags: ${{ steps.get_version.outputs.VERSION }} - push: true \ No newline at end of file + tags: ${{ steps.metadata.outputs.tags }} + push: true diff --git a/Dockerfile b/Dockerfile index d2f242a..102a34a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /app RUN make FROM ubuntu:bionic +LABEL quay.expires-after=1d RUN apt-get -y update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/* COPY --from=builder /app/http_test /app/http_test CMD ["/app/http_test"]