From 85ae9bcea238d4df731f8a3661e0c3400020ad53 Mon Sep 17 00:00:00 2001 From: miko-ov Date: Fri, 15 Dec 2023 09:02:15 +0800 Subject: [PATCH] add workflow for demo1 branch --- .github/workflows/demo1.yaml | 204 +++++++++++++++++++ chart/pixelaw-core/templates/deployment.yaml | 14 +- 2 files changed, 211 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/demo1.yaml diff --git a/.github/workflows/demo1.yaml b/.github/workflows/demo1.yaml new file mode 100644 index 0000000..d83a20e --- /dev/null +++ b/.github/workflows/demo1.yaml @@ -0,0 +1,204 @@ +name: Docker build and deploy to argoCD + +on: + push: + branches: + - demo1 + +jobs: + get-release-version: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Get latest release + id: get-latest-release + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const release = await github.repos.getLatestRelease({ + owner: context.repo.owner, + repo: context.repo.repo + }); + return release.data.tag_name; + + - name: Set ENV variable + run: echo "VERSION=${{ steps.get-latest-release.outputs.result }}" >> $GITHUB_ENV + + - name: Use the VERSION + run: echo "The release version is $VERSION" + + +# name: Docker build and deploy to argoCD +# on: +# push: +# tags: +# - "*" + +# env: +# PROJECTNAME: pixelaw-core +# REGISTRY: ${{ secrets.DOCKERHUB_USERNAME}} +# VERSION: ${{github.ref_name}} + +# defaults: +# run: +# shell: bash + +# jobs: +# buildImage: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout repository +# uses: actions/checkout@v2 +# with: +# submodules: true + + +# - name: Cache node modules +# uses: actions/cache@v2 +# env: +# cache-name: cache-node-modules +# with: +# # npm cache files are stored in `~/.npm` on Linux/macOS +# path: node_modules +# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }} +# restore-keys: | +# ${{ runner.os }}-build-${{ env.cache-name }}- +# ${{ runner.os }}-build- +# ${{ runner.os }}- + + +# - name: Login to Dockerhub +# uses: docker/login-action@v2 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME}} +# password: ${{ secrets.DOCKERHUB_TOKEN }} + +# # - name: push README to Dockerhub +# # uses: christian-korneck/update-container-description-action@v1 +# # env: +# # DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME}} +# # DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }} + +# # with: +# # destination_container_repo: oostvoort/pixelaw +# # provider: dockerhub +# # short_description: '' +# # readme_file: 'README.md' + +# - name: Build, tag, and push image +# id: build-image +# run: | +# docker build -t $REGISTRY/$PROJECTNAME:${VERSION} -t $REGISTRY/$PROJECTNAME:latest . +# docker push $REGISTRY/$PROJECTNAME:latest +# docker push $REGISTRY/$PROJECTNAME:${VERSION} + +# testImage: +# needs: [buildImage] +# runs-on: ubuntu-latest +# steps: +# - name: Run Trivy vulnerability scanner +# uses: aquasecurity/trivy-action@master +# with: +# scan-type: 'image' +# image-ref: 'oostvoort/pixelaw-core:latest' +# severity: 'HIGH,CRITICAL' +# exit-code: '0' + +# helmTest: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Install Helm +# run: | +# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 +# chmod 700 get_helm.sh +# ./get_helm.sh + +# - name: Lint Helm Chart +# run: | +# helm lint --values ./chart/$PROJECTNAME/values.yaml ./chart/$PROJECTNAME + +# helmRelease: +# needs: [helmTest] +# runs-on: ubuntu-latest +# permissions: +# contents: write +# pull-requests: write +# steps: +# - name: Checkout +# uses: actions/checkout@v2 +# with: +# fetch-depth: 0 + +# - name: Configure Git +# run: | +# git config user.name "$GITHUB_ACTOR" +# git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + +# - name: Install Helm +# uses: azure/setup-helm@v1 +# with: +# version: v3.8.1 + +# - name: custom packaging +# run: | +# VERSION=${{github.ref_name}} +# rm -rf .cr-release-packages +# mkdir -p .cr-release-packages +# helm package chart/$PROJECTNAME --app-version=${VERSION:1} --version=${VERSION:1} --destination=.cr-release-packages + +# - name: Run chart-releaser +# # switch back to helm/chart-releaser-action if this contribution is ever mergedd +# uses: askcloudarchitech/chart-releaser-action@skip-packaging-option +# with: +# skip_packaging: true +# env: +# CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + +# - name: Create GitHub Release +# env: +# GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" +# run: | +# TAG=${{ github.ref }} +# VERSION=${TAG#refs/tags/} +# gh release create $VERSION -t $VERSION -n "Release notes for $VERSION" + + +# deploy: +# needs: [testImage] +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 + +# - name: Install ArgoCD CLI if not exists +# run: | +# if ! command -v argocd &> /dev/null; then +# curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 +# chmod +x /usr/local/bin/argocd +# fi + +# - name: Deploy Application Dry Run +# env: +# ARGOCD_SERVER: ${{ secrets.ARGOCD_SERVER }} +# ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_AUTH_TOKEN }} +# run: | +# argocd app create $PROJECTNAME \ +# --repo https://pixelaw.github.io/core/ \ +# --path chart/ \ +# --revision ${VERSION:1} \ +# --helm-chart $PROJECTNAME \ +# --dest-namespace $PROJECTNAME-main \ +# --dest-server https://kubernetes.default.svc \ +# --helm-set-string dockerImage=$REGISTRY/$PROJECTNAME:${VERSION} \a +# --upsert \ +# --server $ARGOCD_SERVER \ +# --auth-token $ARGOCD_AUTH_TOKEN +# argocd app sync $PROJECTNAME +# argocd app wait $PROJECTNAME \ No newline at end of file diff --git a/chart/pixelaw-core/templates/deployment.yaml b/chart/pixelaw-core/templates/deployment.yaml index 34670b4..bfd86a6 100644 --- a/chart/pixelaw-core/templates/deployment.yaml +++ b/chart/pixelaw-core/templates/deployment.yaml @@ -24,20 +24,20 @@ spec: - containerPort: {{ .Values.webappContainerService.port }} env: - name: PUBLIC_NODE_URL - value: "https://api.cartridge.gg/x/pixelaw/katana" + value: "https://api.cartridge.gg/x/pixelaw1/katana" - name: PUBLIC_TORII - value: "https://api.cartridge.gg/x/pixelaw/torii" + value: "https://api.cartridge.gg/x/pixelaw1/torii" - name: SLOT_KATANA - value: "https://api.cartridge.gg/x/pixelaw/katana" + value: "https://api.cartridge.gg/x/pixelaw1/katana" - name: SLOT_TORII - value: "https://api.cartridge.gg/x/pixelaw/torii" + value: "https://api.cartridge.gg/x/pixelaw1/torii" - name: SEED - value: "17885659508068513399" + value: "7380699824140797174" - name: TOTAL_ACCOUNTS value: "4" - name: WORLD_ADDRESS - value: "0x6395ccab8983e6598b8d54bac18cadb63d04b8e4631bde418a2cfb504b59a89" - + value: "0x662b50ea51bf4b9b4a72e48d189d11d4224456c06256f0d57d1756d2d909c47" + # resources: # requests: # memory: "512Mi"