add(ci): migrate to GitHub Actions CI #6
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
name: Deploy | |
on: | |
push: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
env: | |
PROJECT: yayingongyu | |
S3_DOMAIN: cos.accelerate.myqcloud.com | |
S3_BUCKET: luotianyi-dev-1251131545 | |
S3_PREFIX: web/host | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Install Dependencies | |
run: pip install git+https://github.com/luotianyi-dev/deploykit.git | |
- name: Patch nginx.conf | |
run: | | |
sed -i "s@# If assets hosted on CDN then replace this line@return 307 $CDN_URL\$request_uri;@g" server.conf | |
cat server.conf | |
env: | |
CDN_URL: https://${{ env.S3_BUCKET }}${{ env.S3_DOMAIN }}/${{ env.S3_PREFIX }}/${{ env.PROJECT }} | |
- name: Upload to DeployKit | |
run: deployctl deploy upload --commit ${{ github.sha }} -f html public -f server.conf server.conf --switch | |
env: | |
API_KEY: ${{ secrets.API_KEY }} | |
- name: Upload to S3 | |
run: deployctl s3 --bucket $S3_BUCKET --prefix $S3_PREFIX/$PROJECT -f assets | |
env: | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
S3_ENDPOINT: https://${{ env.S3_DOMAIN }} | |
working-directory: ./html |