Skip to content

Commit

Permalink
Merge pull request #142 from Somefive/fix/ci-docker-login
Browse files Browse the repository at this point in the history
Fix: ci docker login
  • Loading branch information
Somefive authored May 30, 2023
2 parents dc78c93 + dc17e76 commit 43d318e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 120 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ on:
push:
branches:
- master
- release-*
tags:
- 'v*'
workflow_dispatch: {}

jobs:
build-push-acr-and-ghcr-image:
build-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -22,24 +23,24 @@ jobs:
uses: docker/metadata-action@v4
with:
images: |
oamdev/cluster-gateway
ghcr.io/oam-dev/cluster-gateway
acr.kubevela.net/oamdev/cluster-gateway
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable={{is_default_branch}}
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to ACR Registry
uses: docker/login-action@v2
with:
registry: acr.kubevela.net
username: ${{ vars.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
# Common versions
GO_VERSION: '1.19'
GOLANGCI_VERSION: 'v1.49'
KIND_VERSION: 'v0.17.0'
KIND_VERSION: 'v0.19.0'

jobs:

Expand Down
80 changes: 0 additions & 80 deletions .github/workflows/go-postsubmit.yml

This file was deleted.

68 changes: 37 additions & 31 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: GoRelease
on:
push:
tags:
- 'v*.*.*'
- 'v*'
env:
# Common versions
GO_VERSION: '1.19'
Expand Down Expand Up @@ -64,16 +64,16 @@ jobs:
OS=linux \
ARCH=${{ matrix.arch }} \
make image
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: push image multi arch
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
docker push oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
docker push oamdev/cluster-gateway-addon-manager:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
- name: push image multi arch to acr
run: |
docker tag oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }} ${{ secrets.ACR_DOMAIN }}/oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
echo ${{ secrets.ACR_PASSWORD }} | docker login ${{ secrets.ACR_DOMAIN }} --username ${{ secrets.ACR_USERNAME }} --password-stdin
docker push ${{ secrets.ACR_DOMAIN }}/oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-${{ matrix.arch }}
image-manifest:
name: image-manifest
runs-on: ubuntu-latest
Expand All @@ -84,9 +84,14 @@ jobs:
with:
fetch-depth: 1
path: go/src/oamdev/cluster-gateway
- name: Login docker.io
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: create
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USER }} --password-stdin
docker manifest create oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }} \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-amd64 \
oamdev/cluster-gateway:${{ needs.env.outputs.RELEASE_VERSION }}-arm64
Expand Down Expand Up @@ -133,26 +138,27 @@ jobs:
artifacts: "go/src/oamdev/cluster-gateway/release/*.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
allowUpdates: true
- name: submit charts to OCM chart repo
uses: actions/github-script@v6
with:
debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }}
github-token: ${{ secrets.PAT_TOKEN }}
script: |
try {
const result = await github.rest.actions.createWorkflowDispatch({
owner: 'open-cluster-management-io',
repo: 'helm-charts',
workflow_id: 'download-chart.yml',
ref: 'main',
inputs: {
repo: "${{ github.repository }}",
version: "${{ needs.env.outputs.TRIMED_RELEASE_VERSION }}",
"chart-name": "cluster-gateway-addon-manager",
},
})
console.log(result);
} catch(error) {
console.error(error);
core.setFailed(error);
}
# lack secrets.PAT_TOKEN from ocm, commented now
# - name: submit charts to OCM chart repo
# uses: actions/github-script@v6
# with:
# debug: ${{ secrets.ACTIONS_RUNNER_DEBUG }}
# github-token: ${{ secrets.PAT_TOKEN }}
# script: |
# try {
# const result = await github.rest.actions.createWorkflowDispatch({
# owner: 'open-cluster-management-io',
# repo: 'helm-charts',
# workflow_id: 'download-chart.yml',
# ref: 'main',
# inputs: {
# repo: "${{ github.repository }}",
# version: "${{ needs.env.outputs.TRIMED_RELEASE_VERSION }}",
# "chart-name": "cluster-gateway-addon-manager",
# },
# })
# console.log(result);
# } catch(error) {
# console.error(error);
# core.setFailed(error);
# }

0 comments on commit 43d318e

Please sign in to comment.