From 194cb45ebec4e100a3a74caaa19aec55250fa070 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Mon, 15 Jan 2024 13:57:52 +0100 Subject: [PATCH 1/3] CI/CD options --- .github/workflows/ci-cd.yaml | 73 +++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index b44ae3b..72d8073 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -19,29 +19,60 @@ jobs: - name: Build the project run: | make build - - container-build-and-push-sha: - runs-on: ubuntu-latest + + socket-exporter-build-dev: + uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.12.3 + name: Build us-west1-docker.pkg.dev/devopsre/dev-images/socket-exporter needs: build permissions: contents: read id-token: write security-events: write - steps: - - uses: actions/checkout@v4 - - name: Login at GCP Artifact Registry - uses: celo-org/reusable-workflows/.github/actions/auth-gcp-artifact-registry@main - with: - workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter-main/providers/github-by-repos' - service-account: 'socket-exporter@devopsre.iam.gserviceaccount.com' - docker-gcp-registries: us-west1-docker.pkg.dev - - name: Build and push container - uses: celo-org/reusable-workflows/.github/actions/build-container@main - with: - platforms: linux/amd64,linux/arm64 - registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter - tag: ${{ github.sha }} - context: . - dockerfile: ./Dockerfile - push: ${{ fromJSON(true) }} - load: ${{ fromJSON(false) }} + if: | + github.ref != 'refs/heads/main' + with: + workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter/providers/github-by-repos' + service-account: 'socket-exporter-dev@devopsre.iam.gserviceaccount.com' + artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/socket-exporter + tag: test + context: . + dockerfile: ./Dockerfile + trivy: true + + socket-exporter-build-main: + uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.12.3 + name: Build us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter + needs: build + permissions: + contents: read + id-token: write + security-events: write + if: | + github.ref == 'refs/heads/main' + with: + workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter-main/providers/github-by-repos' + service-account: 'socket-exporter@devopsre.iam.gserviceaccount.com' + artifact-registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter + tag: latest + context: . + dockerfile: ./Dockerfile + trivy: true + + socket-exporter-build-tag: + uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.12.3 + name: Build us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter tag + needs: build + permissions: + contents: read + id-token: write + security-events: write + if: | + startsWith(github.ref, 'refs/tags/socket-exporter-') + with: + workload-id-provider: projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter/providers/github-by-repos + service-account: 'social-connect@devopsre.iam.gserviceaccount.com' + artifact-registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter + tag: ${{ github.ref_name }} + context: . + dockerfile: ./Dockerfile + trivy: true From 4d3a9e87e1d32abeb730b36453b999cc99b86063 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Mon, 15 Jan 2024 14:00:06 +0100 Subject: [PATCH 2/3] file --- .github/workflows/ci-cd.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 72d8073..2aa511c 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -36,7 +36,7 @@ jobs: artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/socket-exporter tag: test context: . - dockerfile: ./Dockerfile + file: ./Dockerfile trivy: true socket-exporter-build-main: @@ -55,7 +55,7 @@ jobs: artifact-registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter tag: latest context: . - dockerfile: ./Dockerfile + file: ./Dockerfile trivy: true socket-exporter-build-tag: @@ -74,5 +74,5 @@ jobs: artifact-registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter tag: ${{ github.ref_name }} context: . - dockerfile: ./Dockerfile + file: ./Dockerfile trivy: true From 3815e0ca69b5f1b4d9ebe338d5cd16dfd489184c Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Mon, 15 Jan 2024 14:07:01 +0100 Subject: [PATCH 3/3] Workflow vers --- .github/workflows/ci-cd.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 2aa511c..7136249 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -21,7 +21,7 @@ jobs: make build socket-exporter-build-dev: - uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.12.3 + uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.14.1 name: Build us-west1-docker.pkg.dev/devopsre/dev-images/socket-exporter needs: build permissions: @@ -34,13 +34,13 @@ jobs: workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter/providers/github-by-repos' service-account: 'socket-exporter-dev@devopsre.iam.gserviceaccount.com' artifact-registry: us-west1-docker.pkg.dev/devopsre/dev-images/socket-exporter - tag: test + tags: test context: . file: ./Dockerfile trivy: true socket-exporter-build-main: - uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.12.3 + uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.14.1 name: Build us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter needs: build permissions: @@ -53,13 +53,13 @@ jobs: workload-id-provider: 'projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter-main/providers/github-by-repos' service-account: 'socket-exporter@devopsre.iam.gserviceaccount.com' artifact-registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter - tag: latest + tags: latest context: . file: ./Dockerfile trivy: true socket-exporter-build-tag: - uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.12.3 + uses: celo-org/reusable-workflows/.github/workflows/container-cicd.yaml@v1.14.1 name: Build us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter tag needs: build permissions: @@ -72,7 +72,7 @@ jobs: workload-id-provider: projects/1094498259535/locations/global/workloadIdentityPools/gh-socket-exporter/providers/github-by-repos service-account: 'social-connect@devopsre.iam.gserviceaccount.com' artifact-registry: us-west1-docker.pkg.dev/devopsre/socket-exporter/socket-exporter - tag: ${{ github.ref_name }} + tags: ${{ github.ref_name }} context: . file: ./Dockerfile trivy: true