Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.10] ci: use staging registry for hotfixes (#3055) #3117

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions .github/workflows/release-fleet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ env:

jobs:
build-fleet:
runs-on: ubuntu-latest
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 @@ -36,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 @@ -74,12 +77,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
39 changes: 21 additions & 18 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,14 +81,6 @@ builds:
- linux_arm64
- windows_amd64

changelog:
## Delegate Changelog to release-drafter
disable: false
use: github-native

env:
- CGO_ENABLED=0

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

Expand All @@ -99,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 @@ -124,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 @@ -145,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 @@ -164,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 @@ -179,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"
Loading