From e7ef7c49f366236882afe3389cebe5bb8ae4192b Mon Sep 17 00:00:00 2001 From: joyceliu Date: Mon, 30 Oct 2023 11:36:57 +0800 Subject: [PATCH] fix(action): change image-registry and tag retrieval method --- .github/workflows/main.yaml | 75 ++++++++------------------- .github/workflows/manually.yaml | 63 ---------------------- .github/workflows/nightly-builds.yaml | 4 +- .github/workflows/release.yml | 5 +- 4 files changed, 26 insertions(+), 121 deletions(-) delete mode 100644 .github/workflows/manually.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b87cd4b8cb6..9cf08f4a608 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,65 +4,36 @@ on: push: # Publish `master` as Docker `latest` image. branches: -# - master + - master # - dev - - release-* - - # Publish `v1.2.3` tags as releases. - tags: - - v* - + - release-* # Run build for any PRs. pull_request: -jobs: - build-and-push: - runs-on: self-hosted - - strategy: - matrix: - node-version: [12.18.x] +env: + # TODO: Change variable to your image's name. + IMAGE_NAME: ks-console + IMAGE_REPO: kubespheredev +jobs: + release-linux-amd64: + runs-on: ubuntu-latest + if: github.repository == 'kubesphere/console' steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i -g yarn && yarn - - - name: Build - run: yarn build - - - name: Test - run: yarn test + - uses: actions/checkout@v2 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all - - name: Docker login - if: github.event_name == 'push' - uses: docker/login-action@v1 - with: - registry: registry.cn-beijing.aliyuncs.com - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Set up Docker buildx + uses: docker/setup-buildx-action@v1 - - name: Push image - if: github.event_name == 'push' - run: | - TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') REPO=registry.cn-beijing.aliyuncs.com/kubesphereio make container-cross-push + - name: Log into registry + run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin - - name: slack - uses: 8398a7/action-slack@v3 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - status: ${{ job.status }} - fields: repo,message,commit,author,action,eventName,ref,workflow,job,took - if: failure() \ No newline at end of file + - name: Push image + run: | + TAG=${GITHUB_REF#refs/*/} REPO=$IMAGE_REPO make container-cross-push + echo "Push $IMAGE success!" diff --git a/.github/workflows/manually.yaml b/.github/workflows/manually.yaml deleted file mode 100644 index bb50f0b73c1..00000000000 --- a/.github/workflows/manually.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: ManuallyCrossBuild - -on: - workflow_dispatch: - -jobs: - build-and-push: - runs-on: self-hosted - - strategy: - matrix: - node-version: [12.18.x] - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - name: Install Dependencies - run: npm i -g yarn && yarn - - - name: Build - run: yarn build - - - name: Test - run: yarn test - - - name: Set up QEMU - if: github.event_name == 'push' - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - if: github.event_name == 'push' - id: buildx - uses: docker/setup-buildx-action@v1 - with: - version: v0.7.1 - install: true - - - name: Docker login - if: github.event_name == 'push' - uses: docker/login-action@v1 - with: - registry: registry.cn-beijing.aliyuncs.com - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Push image - if: github.event_name == 'push' - run: | - TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') REPO=registry.cn-beijing.aliyuncs.com/kubesphereio make container-cross-push - - - name: slack - uses: 8398a7/action-slack@v3 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - with: - status: ${{ job.status }} - fields: repo,message,commit,author,action,eventName,ref,workflow,job,took - if: failure() \ No newline at end of file diff --git a/.github/workflows/nightly-builds.yaml b/.github/workflows/nightly-builds.yaml index c465212a1e0..b205dda1e46 100644 --- a/.github/workflows/nightly-builds.yaml +++ b/.github/workflows/nightly-builds.yaml @@ -44,13 +44,13 @@ jobs: - name: Docker login uses: docker/login-action@v1 with: - registry: registry.cn-beijing.aliyuncs.com + registry: docker.io username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Push image run: | - TAG=nightly-$(date '+%Y%m%d') REPO=registry.cn-beijing.aliyuncs.com/kubesphereio make container-cross-push + TAG=nightly-$(date '+%Y%m%d') REPO=docker.io/kubespheredev make container-cross-push # - name: slack # uses: 8398a7/action-slack@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cbb2e02c9d..7608a702b32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,6 @@ jobs: if: github.repository == 'kubesphere/console' steps: - uses: actions/checkout@v2 - - name: Get Version - id: get_version - run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -33,5 +30,5 @@ jobs: - name: Push image run: | - TAG=${{ steps.get_version.outputs.VERSION }} REPO=$IMAGE_REPO make container-cross-push + TAG=${GITHUB_REF#refs/*/} REPO=$IMAGE_REPO make container-cross-push echo "Push $IMAGE success!"