From 0a71fafeb4d22c7570a3b9ce022718d37d1e6ba0 Mon Sep 17 00:00:00 2001 From: YanJin Date: Fri, 5 Apr 2024 15:53:36 +0200 Subject: [PATCH] push the build to ghcr.io --- .github/workflows/build-push-tests.yml | 75 ++++++++++++-------------- .github/workflows/release.yaml | 22 ++++---- 2 files changed, 44 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-push-tests.yml b/.github/workflows/build-push-tests.yml index e9a221e0f..ce9159d3e 100644 --- a/.github/workflows/build-push-tests.yml +++ b/.github/workflows/build-push-tests.yml @@ -4,40 +4,39 @@ name: build, push to registry and tests on: push: branches-ignore: - - 'development/**' + - "development/**" env: - NAMESPACE: 'zenko-ui-dev' - REGISTRY: 'registry.scality.com' + NAMESPACE: "scality/zenko-ui/dev" + REGISTRY: "ghcr.io" jobs: - oras: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Oras - run: | - curl -LO https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz - mkdir -p oras-install/ - sudo tar -zxf oras_${ORAS_VERSION}_*.tar.gz -C /usr/local/bin oras - rm -rf oras_${ORAS_VERSION}_*.tar.gz oras-install/ - env: - ORAS_VERSION: '0.12.0' - - - name: Oras login - run: oras login --username "${LOGIN}" --password "${PASSWORD}" ${REGISTRY} - env: - LOGIN: '${{ secrets.REGISTRY_LOGIN }}' - PASSWORD: '${{ secrets.REGISTRY_PASSWORD }}' - - - name: push nginx and runtime-app-configuration - run: | - oras push ${REGISTRY}/${NAMESPACE}/zenko-ui-config:${{ github.sha }} \ - runtime-app-configuration.gotempl:application/zenko-ui-runtime-config-template+json \ - nginx.conf.gotempl:text/nginx-conf-template + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Oras + run: | + curl -LO https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz + mkdir -p oras-install/ + sudo tar -zxf oras_${ORAS_VERSION}_*.tar.gz -C /usr/local/bin oras + rm -rf oras_${ORAS_VERSION}_*.tar.gz oras-install/ + env: + ORAS_VERSION: "0.12.0" + + - name: Oras login + run: oras login --username "${LOGIN}" --password "${PASSWORD}" ${REGISTRY} + env: + LOGIN: "${{ github.actor }}" + PASSWORD: "${{ github.token }}" + + - name: push nginx and runtime-app-configuration + run: | + oras push ${REGISTRY}/${NAMESPACE}/zenko-ui-config:${{ github.sha }} \ + runtime-app-configuration.gotempl:application/zenko-ui-runtime-config-template+json \ + nginx.conf.gotempl:text/nginx-conf-template build: runs-on: ubuntu-20.04 @@ -50,25 +49,18 @@ jobs: - uses: actions/setup-node@v2.4.1 with: - node-version: '16' - cache: 'npm' + node-version: "16" + cache: "npm" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to GitHub Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to Scality Registry uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} - username: ${{ secrets.REGISTRY_LOGIN }} - password: ${{ secrets.REGISTRY_PASSWORD}} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: install dependencies run: npm config set unsafe-perm true && npm ci @@ -82,8 +74,7 @@ jobs: push: true context: . tags: | - ghcr.io/${{ github.repository }}/zenko-ui:${{ github.sha }} - ${{env.REGISTRY}}/${{env.NAMESPACE}}/zenko-ui:${{ github.sha }} + ${{env.REGISTRY}}/${{env.NAMESPACE}}:${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max @@ -93,8 +84,8 @@ jobs: - uses: actions/checkout@v2.3.5 - uses: actions/setup-node@v2.4.1 with: - node-version: '16' - cache: 'npm' + node-version: "16" + cache: "npm" - name: install dependencies run: npm config set unsafe-perm true && npm ci - name: run eslint test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8c524e134..e934368d3 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,11 +5,11 @@ on: release: types: [published] env: - DEV_NAMESPACE: 'zenko-ui-dev' - PROD_NAMESPACE: 'zenko-ui' - REGISTRY: 'registry.scality.com' - CONFIG_IMAGE: 'zenko-ui-config' - UI_IMAGE: 'zenko-ui' + DEV_NAMESPACE: "scality/zenko-ui/dev" + PROD_NAMESPACE: "scality/zenko-ui" + REGISTRY: "ghcr.io" + CONFIG_IMAGE: "zenko-ui-config" + UI_IMAGE: "zenko-ui" jobs: retag-docker-image: @@ -19,12 +19,12 @@ jobs: uses: actions/checkout@v2.3.5 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Login to Registry + - name: Login to registry uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} - username: ${{ secrets.REGISTRY_LOGIN }} - password: ${{ secrets.REGISTRY_PASSWORD }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Install Oras run: | curl -LO https://github.com/oras-project/oras/releases/download/v${ORAS_VERSION}/oras_${ORAS_VERSION}_linux_amd64.tar.gz @@ -32,12 +32,12 @@ jobs: sudo tar -zxf oras_${ORAS_VERSION}_*.tar.gz -C /usr/local/bin oras rm -rf oras_${ORAS_VERSION}_*.tar.gz oras-install/ env: - ORAS_VERSION: '0.12.0' + ORAS_VERSION: "0.12.0" - name: Oras login run: oras login --username "${LOGIN}" --password "${PASSWORD}" ${REGISTRY} env: - LOGIN: '${{ secrets.REGISTRY_LOGIN }}' - PASSWORD: '${{ secrets.REGISTRY_PASSWORD }}' + LOGIN: "${{ github.actor }}" + PASSWORD: "${{ github.token }}" - name: push nginx and runtime-app-configuration run: |