nocobase/.github/workflows/manual_deploy_fork_pr.yml

114 lines
4.4 KiB
YAML
Raw Normal View History

2022-11-30 08:12:00 +00:00
name: manual_down_deploy_pr
# deploy_host
# deploy_host_username
# deploy_host_password
env:
nocobase_deploy_sh_dir: /home/ecs-user/nocobase/auto-deploy-pr/
2022-11-30 08:12:00 +00:00
on:
workflow_dispatch:
inputs:
pr_number:
description: 'fork pr number is '
required: true
jobs:
up_deploy:
runs-on: ubuntu-latest
services:
verdaccio:
image: verdaccio/verdaccio
ports:
- 4873:4873
steps:
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
# Optional, GitHub token, a Personal Access Token with `public_repo` scope if needed
# Required, if the artifact is from a different repo
# Required, if the repo is private a Personal Access Token with `repo` scope is needed
github_token: ${{secrets.GITHUB_TOKEN}}
# Optional, workflow file name or ID
# If not specified, will be inferred from run_id (if run_id is specified), or will be the current workflow
workflow: upload_fork_pr_files.yml
# Optional, the status or conclusion of a completed workflow to search for
# Can be one of a workflow conclusion:
# "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required"
# Or a workflow status:
# "completed", "in_progress", "queued"
# Use the empty string ("") to ignore status or conclusion in the search
workflow_conclusion: success
# Optional, will get head commit SHA
pr: ${{ inputs.pr_number }}
# Optional, no need to specify if PR is
# commit: ${{github.event.pull_request.head.sha}}
# Optional, will use the specified branch. Defaults to all branches
# branch: master
# Optional, defaults to all types
# event: push
# Optional, will use specified workflow run
# run_id: 1122334455
# Optional, run number from the workflow
# run_number: 34
# Optional, uploaded artifact name,
# will download all artifacts if not specified
# and extract them into respective subdirectories
# https://github.com/actions/download-artifact#download-all-artifacts
name: pr_files
# Optional, a directory where to extract artifact(s), defaults to the current directory
# path: extract_here
# Optional, defaults to current repo
# repo: ${{ github.repository }}
# Optional, check the workflow run to whether it has an artifact
# then will get the last available artifact from the previous workflow
# default false, just try to download from the last one
# check_artifacts: false
# Optional, search for the last workflow run whose stored an artifact named as in `name` input
# default false
search_artifacts: false
# Optional, choose to skip unpacking the downloaded artifact(s)
# default false
skip_unpack: false
# Optional, choose how to exit the action if no artifact is found
# can be one of:
# "fail", "warn", "ignore"
# default fail
if_no_artifact_found: fail
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: network=host
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ${{ secrets.ALI_DOCKER_REGISTRY }}
username: ${{ secrets.ALI_DOCKER_USERNAME }}
password: ${{ secrets.ALI_DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
build-args: |
VERDACCIO_URL=http://localhost:4873/
COMMIT_HASH=${GITHUB_SHA}
push: true
tags: ${{ secrets.ALI_DOCKER_REGISTRY }}/nocobase/nocobase:pr-${{ inputs.pr_number }}
- name: ssh deploy
uses: appleboy/ssh-action@master
env:
pr_number: ${{ inputs.pr_number }}
with:
host: ${{ secrets.deploy_host }}
username: ${{ secrets.deploy_host_username }}
password: ${{ secrets.deploy_host_password }}
script: |
cd ${{ env.nocobase_deploy_sh_dir }}
./nocobase-deploy.sh up ${{ env.pr_number }}