From 249a87366ba32c229c4d8b9e08f995a95d9e00c5 Mon Sep 17 00:00:00 2001 From: incubator4 Date: Mon, 1 Jan 2024 13:41:48 +0800 Subject: [PATCH] chore(deploy): fix ci branch env --- .github/workflows/docker-build-push-dev.yaml | 65 +++++++++ .github/workflows/docker-build-push-prod.yaml | 64 +++++++++ .github/workflows/docker-build-push.yaml | 129 ------------------ 3 files changed, 129 insertions(+), 129 deletions(-) create mode 100644 .github/workflows/docker-build-push-dev.yaml create mode 100644 .github/workflows/docker-build-push-prod.yaml delete mode 100644 .github/workflows/docker-build-push.yaml diff --git a/.github/workflows/docker-build-push-dev.yaml b/.github/workflows/docker-build-push-dev.yaml new file mode 100644 index 00000000..4a050e0c --- /dev/null +++ b/.github/workflows/docker-build-push-dev.yaml @@ -0,0 +1,65 @@ +# build and push docker image to docker hub +name: Build & Deploy Dev + +on: + push: + branches: + - "dev" + +jobs: + build: + runs-on: ubuntu-latest + environment: Preview + outputs: + version: ${{ steps.meta.outputs.version }} + steps: + - uses: hmarr/debug-action@v2 + - name: Checkout + uses: actions/checkout@v4 + - name: docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: rss3/xlog + tags: | + type=sha,prefix={{branch}}- + type=sha,format=long,prefix={{branch}}- + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + "NEXT_PUBLIC_DISCORD_LINK=${{ vars.NEXT_PUBLIC_DISCORD_LINK }}" + "NEXT_PUBLIC_GITHUB_LINK=${{ vars.NEXT_PUBLIC_GITHUB_LINK }}" + "NEXT_PUBLIC_OUR_DOMAIN=${{ vars.NEXT_PUBLIC_OUR_DOMAIN }}" + "NEXT_PUBLIC_TWITTER_LINK=${{ vars.NEXT_PUBLIC_TWITTER_LINK }}" + "NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID=${{ vars.NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID }}" + "NEXT_PUBLIC_IPFS_GATEWAY=${{ vars.NEXT_PUBLIC_IPFS_GATEWAY }}" + + deploy: + if: github.ref == 'refs/heads/dev' + uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main + needs: + - build + with: + images: rss3/xlog + tag: dev-${{ github.sha }} + cluster: dev + namespace: crossbell + releaseName: xlog + revision: dev + dir: deploy/dev + secrets: + GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} diff --git a/.github/workflows/docker-build-push-prod.yaml b/.github/workflows/docker-build-push-prod.yaml new file mode 100644 index 00000000..ac2b8305 --- /dev/null +++ b/.github/workflows/docker-build-push-prod.yaml @@ -0,0 +1,64 @@ +# build and push docker image to docker hub +name: Build & Deploy Dev + +on: + push: + branches: + - "main" + +jobs: + build: + runs-on: ubuntu-latest + environment: Production + outputs: + version: ${{ steps.meta.outputs.version }} + steps: + - uses: hmarr/debug-action@v2 + - name: Checkout + uses: actions/checkout@v4 + - name: docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: rss3/xlog + tags: | + type=sha,prefix={{branch}}- + type=sha,format=long,prefix={{branch}}- + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + "NEXT_PUBLIC_DISCORD_LINK=${{ vars.NEXT_PUBLIC_DISCORD_LINK }}" + "NEXT_PUBLIC_GITHUB_LINK=${{ vars.NEXT_PUBLIC_GITHUB_LINK }}" + "NEXT_PUBLIC_OUR_DOMAIN=${{ vars.NEXT_PUBLIC_OUR_DOMAIN }}" + "NEXT_PUBLIC_TWITTER_LINK=${{ vars.NEXT_PUBLIC_TWITTER_LINK }}" + "NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID=${{ vars.NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID }}" + "NEXT_PUBLIC_IPFS_GATEWAY=${{ vars.NEXT_PUBLIC_IPFS_GATEWAY }}" + + deploy: + uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main + needs: + - build + with: + images: rss3/xlog + tag: main-${{ github.sha }} + cluster: prod + namespace: crossbell + releaseName: xlog + revision: main + dir: deploy/prod + secrets: + GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml deleted file mode 100644 index 61570927..00000000 --- a/.github/workflows/docker-build-push.yaml +++ /dev/null @@ -1,129 +0,0 @@ -# build and push docker image to docker hub -name: Build & Deploy Dev - -on: - push: - branches: - - "dev" - - "main" - -env: - IMAGE_NAME: rss3/xlog - REGION_ID: us-east-1 - ACK_CLUSTER_ID: cd1d0ffc40b5242b39ddda1864e71e30d - -jobs: - build-dev: - if: github.ref == 'refs/heads/dev' - runs-on: ubuntu-latest - environment: Preview - outputs: - version: ${{ steps.meta.outputs.version }} - steps: - - uses: hmarr/debug-action@v2 - - name: Checkout - uses: actions/checkout@v4 - - name: docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: rss3/xlog - tags: | - type=sha,prefix={{branch}}- - type=sha,format=long,prefix={{branch}}- - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - "NEXT_PUBLIC_DISCORD_LINK=${{ vars.NEXT_PUBLIC_DISCORD_LINK }}" - "NEXT_PUBLIC_GITHUB_LINK=${{ vars.NEXT_PUBLIC_GITHUB_LINK }}" - "NEXT_PUBLIC_OUR_DOMAIN=${{ vars.NEXT_PUBLIC_OUR_DOMAIN }}" - "NEXT_PUBLIC_TWITTER_LINK=${{ vars.NEXT_PUBLIC_TWITTER_LINK }}" - "NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID=${{ vars.NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID }}" - "NEXT_PUBLIC_IPFS_GATEWAY=${{ vars.NEXT_PUBLIC_IPFS_GATEWAY }}" - - build-prod: - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - environment: Production - outputs: - version: ${{ steps.meta.outputs.version }} - steps: - - uses: hmarr/debug-action@v2 - - name: Checkout - uses: actions/checkout@v4 - - name: docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: rss3/xlog - tags: | - type=sha,prefix={{branch}}- - type=sha,format=long,prefix={{branch}}- - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to DockerHub - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - file: Dockerfile - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - "NEXT_PUBLIC_DISCORD_LINK=${{ vars.NEXT_PUBLIC_DISCORD_LINK }}" - "NEXT_PUBLIC_GITHUB_LINK=${{ vars.NEXT_PUBLIC_GITHUB_LINK }}" - "NEXT_PUBLIC_OUR_DOMAIN=${{ vars.NEXT_PUBLIC_OUR_DOMAIN }}" - "NEXT_PUBLIC_TWITTER_LINK=${{ vars.NEXT_PUBLIC_TWITTER_LINK }}" - "NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID=${{ vars.NEXT_PUBLIC_WALLET_CONNECT_V2_PROJECT_ID }}" - "NEXT_PUBLIC_IPFS_GATEWAY=${{ vars.NEXT_PUBLIC_IPFS_GATEWAY }}" - - deploy-dev: - if: github.ref == 'refs/heads/dev' - uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main - needs: - - build - with: - images: rss3/xlog - tag: dev-${{ github.sha }} - cluster: dev - namespace: crossbell - releaseName: xlog - revision: dev - dir: deploy/dev - secrets: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} - deploy-prod: - if: github.ref == 'refs/heads/main' - uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main - needs: - - build - with: - images: rss3/xlog - tag: main-${{ github.sha }} - cluster: prod - namespace: crossbell - releaseName: xlog - revision: main - dir: deploy/prod - secrets: - GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}