Skip to content

Commit

Permalink
[migrate] replace User Rank component with the same one in latest Ide…
Browse files Browse the repository at this point in the history
…a-React

[fix] GitHub actions of Production deployment (fix #221)
  • Loading branch information
TechQuery committed Oct 20, 2024
1 parent 1b8a989 commit 2244505
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 446 deletions.
83 changes: 43 additions & 40 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,37 @@
# This is a basic workflow to help you get started with Actions
# reference:
# 1. https://github.com/docker/build-push-action/blob/master/docs/advanced/push-multi-registries.md
# 2. https://github.com/docker/build-push-action/blob/master/docs/advanced/share-image-jobs.md

name: Docker Build, Push and Publish

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
name: Deploy to Production environment
on:
push:
tags:
- v*
env:
ARTIFACT_PATH: artifact.tar
BOX_NAME: ${{ github.event.repository.name }}
BOX_URL: ${{ github.repository }}
DOCKER_BUILD_SUMMARY: false
DOCKER_BUILD_RECORD_UPLOAD: false

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
docker:
deploy_docker_image:
name: Deploy Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: openhackathon/oph-web,kysprodacr.azurecr.cn/oph-web
# add Git short SHA as Docker tag
tags: |
type=sha
- uses: docker/setup-qemu-action@v3

- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESSTOKEN }}

- name: Login to Azure Container Registry
uses: docker/login-action@v3
with:
registry: kysprodacr.azurecr.cn
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Inject Environment variables
run: |
echo "BOX_NAME=${BOX_NAME@L}" >> "${GITHUB_ENV}"
echo "BOX_URL=${BOX_URL@L}" >> "${GITHUB_ENV}"
cat >> .npmrc <<EOF
//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}
@kaiyuanshe:registry=https://npm.pkg.github.com
Expand All @@ -59,18 +45,35 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: linux/amd64
tags: ${{ env.BOX_URL }}:latest
outputs: type=docker,dest=${{ env.ARTIFACT_PATH }}

- name: Pick Docker Compose
run: |
mkdir ./build
mv ${{ env.ARTIFACT_PATH }} .env* ./docker-compose.yml ./start.sh ./build
- uses: benjlevesque/[email protected]
id: short-sha
- name: Transport Image
uses: appleboy/[email protected]
with:
length: 7
source: ./build/*.*
target: /tmp/${{ env.BOX_NAME }}
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
password: ${{ secrets.SSH_KEY }}
strip_components: 1

- uses: azure/webapps-deploy@v2
- name: Run Image
uses: garygrossgarten/github-action-ssh@release
with:
app-name: ${{ secrets.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
images: 'kysprodacr.azurecr.cn/oph-web:sha-${{ steps.short-sha.outputs.sha }}'
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
password: ${{ secrets.SSH_KEY }}
command: |
cd /tmp/${{ env.BOX_NAME }}
mkdir -p ~/${{ env.BOX_NAME }}
mv .env* docker-compose.yml start.sh ~/${{ env.BOX_NAME }}
cd ~/${{ env.BOX_NAME }}
chmod +x start.sh
echo '${{ secrets.SSH_KEY }}' | sudo -S ./start.sh /tmp/${{ env.BOX_NAME }}/${{ env.ARTIFACT_PATH }}
115 changes: 0 additions & 115 deletions components/User/TopUserList.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions components/User/UserRank/Address.tsx

This file was deleted.

Loading

1 comment on commit 2244505

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for open-hackathon ready!

✅ Preview
https://open-hackathon-56zwrfrxk-techquerys-projects.vercel.app

Built with commit 2244505.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.