From daff9872fbeefc8c38159714b255ff4fd323b284 Mon Sep 17 00:00:00 2001 From: Juan Jose Jaramillo Date: Wed, 8 May 2024 17:49:21 -0700 Subject: [PATCH] feat: Automate Docker image builds with multi-architecture support (#17) --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 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 00000000..52c0503d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: Continuous Integration + +on: + workflow_dispatch: + schedule: + - cron: '0 12 * * *' + push: + branches: + - 'main' + - 'renovate/**' + tags: + - 'v*.*.*' + pull_request: + branches: + - 'main' + +permissions: + contents: read + +jobs: + build: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - name: Checkout GitHub Repository + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + + - name: Docker metadata + id: metadata + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 + with: + images: | + newrelic/k8s-agents-operator + tags: | + # reflects the last commit of the active branch + type=edge + # nightly tag + type=schedule + # push tag event + type=semver,pattern={{version}} + # push tag event + type=semver,pattern={{major}}.{{minor}} + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/heads/renovate') + uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 + with: + username: ${{ secrets.K8S_AGENTS_DOCKERHUB_USERNAME }} + password: ${{ secrets.K8S_AGENTS_DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 + + - name: Build and push + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/heads/renovate') }} + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }}