Skip to content

Commit

Permalink
ci: use staging registry for hotfixes (#3055)
Browse files Browse the repository at this point in the history
  • Loading branch information
aruiz14 authored and thardeck committed Dec 3, 2024
1 parent 35225f2 commit 2215e33
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 19 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/release-fleet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
build-fleet:
runs-on: runs-on,runner=8cpu-linux-x64,mem=16,run-id=${{ github.run_id }}

env:
IS_HOTFIX: ${{ contains(github.ref, '-hotfix-ch-') }}
REGISTRY: "${{ contains(github.ref, '-hotfix-ch-') && 'stgregistry.suse.com' || 'docker.io' }}"

if: github.repository == 'rancher/fleet'
steps:
- name: Check out Fleet
Expand All @@ -37,8 +41,6 @@ jobs:
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
secret/data/github/repo/${{ github.repository }}/fossa/credential token | FOSSA_API_KEY
- name: Run FOSSA scan
Expand Down Expand Up @@ -78,12 +80,30 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: "Read Vault Secrets"
uses: rancher-eio/read-vault-secrets@main
with:
secrets: |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD ;
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials username | STAGE_REGISTRY_USERNAME ;
secret/data/github/repo/${{ github.repository }}/rancher-prime-stg-registry/credentials password | STAGE_REGISTRY_PASSWORD ;
- name: Log into Docker Container registry
uses: docker/login-action@v3
if: ${{ env.IS_HOTFIX == 'false' }}
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_PASSWORD }}

- name: Log into Staging registry
uses: docker/login-action@v3
if: ${{ env.IS_HOTFIX == 'true' }}
with:
username: ${{ env.STAGE_REGISTRY_USERNAME }}
password: ${{ env.STAGE_REGISTRY_PASSWORD }}
registry: ${{ env.REGISTRY }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
id: goreleaser
Expand Down
38 changes: 21 additions & 17 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@
version: 2

project_name: fleet

env:
- CGO_ENABLED=0
- IS_HOTFIX={{ if isEnvSet "IS_HOTFIX"}}{{ .Env.IS_HOTFIX }}{{else}}false{{end}}
- REGISTRY={{ if isEnvSet "REGISTRY" }}{{ .Env.REGISTRY }}{{else}}docker.io{{end}}

release:
prerelease: auto
disable: "{{ .Env.IS_HOTFIX }}"

changelog:
disable: false
use: github-native

before:
hooks:
Expand Down Expand Up @@ -70,13 +81,6 @@ builds:
- linux_arm64
- windows_amd64

changelog:
disable: false
use: github-native

env:
- CGO_ENABLED=0

snapshot:
name_template: "{{ .Tag }}-next"

Expand All @@ -98,7 +102,7 @@ dockers:

# Templates of the Docker image names.
image_templates:
- "docker.io/rancher/fleet:{{ .Tag }}-linux-amd64"
- "{{ .Env.REGISTRY }}/rancher/fleet:{{ .Tag }}-linux-amd64"

# Path to the Dockerfile (from the project root).
dockerfile: package/Dockerfile
Expand All @@ -123,7 +127,7 @@ dockers:
- fleet-controller
- fleet-cli
image_templates:
- "docker.io/rancher/fleet:{{ .Tag }}-linux-arm64"
- "{{ .Env.REGISTRY }}/rancher/fleet:{{ .Tag }}-linux-arm64"
dockerfile: package/Dockerfile
build_flag_templates:
- "--pull"
Expand All @@ -144,7 +148,7 @@ dockers:
ids:
- fleet-agent
image_templates:
- "docker.io/rancher/fleet-agent:{{ .Tag }}-linux-amd64"
- "{{ .Env.REGISTRY }}/rancher/fleet-agent:{{ .Tag }}-linux-amd64"
dockerfile: package/Dockerfile.agent
build_flag_templates:
- "--pull"
Expand All @@ -163,7 +167,7 @@ dockers:
ids:
- fleet-agent
image_templates:
- "docker.io/rancher/fleet-agent:{{ .Tag }}-linux-arm64"
- "{{ .Env.REGISTRY }}/rancher/fleet-agent:{{ .Tag }}-linux-arm64"
dockerfile: package/Dockerfile.agent
build_flag_templates:
- "--pull"
Expand All @@ -178,12 +182,12 @@ dockers:

docker_manifests:
# https://goreleaser.com/customization/docker_manifest/
- name_template: "docker.io/rancher/fleet:{{ .Tag }}"
- name_template: "{{ .Env.REGISTRY }}/rancher/fleet:{{ .Tag }}"
image_templates:
- "docker.io/rancher/fleet:{{ .Tag }}-linux-amd64"
- "docker.io/rancher/fleet:{{ .Tag }}-linux-arm64"
- "{{ .Env.REGISTRY }}/rancher/fleet:{{ .Tag }}-linux-amd64"
- "{{ .Env.REGISTRY }}/rancher/fleet:{{ .Tag }}-linux-arm64"

- name_template: "docker.io/rancher/fleet-agent:{{ .Tag }}"
- name_template: "{{ .Env.REGISTRY }}/rancher/fleet-agent:{{ .Tag }}"
image_templates:
- "docker.io/rancher/fleet-agent:{{ .Tag }}-linux-amd64"
- "docker.io/rancher/fleet-agent:{{ .Tag }}-linux-arm64"
- "{{ .Env.REGISTRY }}/rancher/fleet-agent:{{ .Tag }}-linux-amd64"
- "{{ .Env.REGISTRY }}/rancher/fleet-agent:{{ .Tag }}-linux-arm64"

0 comments on commit 2215e33

Please sign in to comment.