generated from EasyWebApp/WebCell-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[migrate] replace User Rank component with the same one in latest Ide…
…a-React [fix] GitHub actions of Production deployment (fix #221)
- Loading branch information
Showing
11 changed files
with
143 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
9b5f090
There was a problem hiding this comment.
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-h5aooaigb-techquerys-projects.vercel.app
Built with commit 9b5f090.
This pull request is being automatically deployed with vercel-action