From eada0641a1ca66b5351304ea69791272f4de6e03 Mon Sep 17 00:00:00 2001 From: Ashley Dumaine <5779804+AshleyDumaine@users.noreply.github.com> Date: Wed, 3 Apr 2024 10:58:42 -0400 Subject: [PATCH] build and push images on main or tags if tests pass, use main for default image tag (#226) --- .github/workflows/build-push.yml | 34 +++++++++++++++++++++++++ .github/workflows/release.yml | 22 +--------------- config/default/manager_image_patch.yaml | 2 +- 3 files changed, 36 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/build-push.yml diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 000000000..0072fc916 --- /dev/null +++ b/.github/workflows/build-push.yml @@ -0,0 +1,34 @@ +name: Build and Push +on: + push: + branches: + - main + tags: + - "*" + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + needs: go-build-test + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Docker Meta + id: meta + uses: docker/metadata-action@v5 + with: + images: linode/cluster-api-provider-linode + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and Push to Docker Hub + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ace2933ef..c7cea4260 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: jobs: release: runs-on: ubuntu-latest + needs: go-build-test steps: - uses: actions/checkout@v4 with: @@ -20,24 +21,3 @@ jobs: with: files: | ./release - - name: Docker Meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - linode/cluster-api-provider-linode - tags: | - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - type=semver,pattern={{raw}},value=${{ github.ref_name }} - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and Push to Docker Hub - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/config/default/manager_image_patch.yaml b/config/default/manager_image_patch.yaml index 2ee7174cf..c2ad88b8d 100644 --- a/config/default/manager_image_patch.yaml +++ b/config/default/manager_image_patch.yaml @@ -8,5 +8,5 @@ spec: template: spec: containers: - - image: docker.io/linode/cluster-api-provider-linode:v0.1.0 + - image: docker.io/linode/cluster-api-provider-linode:main name: manager