我正在尝试实施 github 操作以将 django 项目部署到我的 Google Compute Engine,但无法实现。
我正在关注本教程:https : //testdriven.io/blog/deploying-django-to-digitalocean-with-docker-and-github-actions/
错误日志说:
/home/runner/work/_temp/f***572db0-***32d-4053-8b60-f5d54780dd7c.sh:第4行:意外标记附近的语法错误`)'
name: Continuous Integration and Delivery
on: [push]
env:
WEB_IMAGE: docker.pkg.github.com/$GITHUB_REPOSITORY/web
CHANNELS_IMAGE: docker.pkg.github.com/$GITHUB_REPOSITORY/channels
jobs:
build:
name: Build Docker Images
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v1
- name: Add environment variables to .env
run: |
echo DEBUG=0 >> .env
echo SQL_ENGINE=django.db.backends.postgresql_pyscopg2 >> .env
echo DATABASE=postgres >> .env
echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
echo SQL_DATABASE=${{ secrets.SQL_DATABASE }} >> .env
echo SQL_USER=${{ secrets.SQL_USER }} >> .env
echo SQL_PASSWORD=${{ secrets.SQL_PASSWORD }} >> .env
echo SQL_HOST=${{ secrets.SQL_HOST }} >> .env
echo SQL_PORT=${{ secrets.SQL_PORT }} >> .env
echo EMAIL_HOST=${{ secrets.EMAIL_HOST }} >> .env
echo EMAIL_PORT=${{ secrets.EMAIL_PORT }} >> .env
echo EMAIL_USE_TLS=${{ secrets.EMAIL_USE_TLS }} >> .env
echo EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }} >> .env
echo EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }} >> .env
echo DEFAULT_FROM_EMAIL=${{ secrets.DEFAULT_FROM_EMAIL }} .env
echo ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL=http://ventinghub.com/auth/sign-in
echo ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL=http://ventinghub.com/
echo SITE_ID=1
echo EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
echo redis_host=redis
- name: Set environment variables
run: |
echo ::set-env name=WEB_IMAGE::${{ env.WEB_IMAGE }}
echo ::set-env name=CHANNELS_IMAGE::${{ env.CHANNELS_IMAGE }}
- name: Log in to GitHub Packages
run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Pull images
run: |
docker pull ${{ env.WEB_IMAGE }} || true
docker pull ${{ env.CHANNELS_IMAGE }} || true
- name: Build images
run: |
docker-compose -f docker-compose.ci.yml build
- name: Push images
run: |
docker push ${{ env.WEB_IMAGE }}
docker push ${{ env.CHANNELS_IMAGE }}
deploy:
name: Deploy to GCP
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout master
uses: actions/checkout@v1
- name: Add environment variables to .env
run: |
echo DEBUG=0 >> .env
echo SQL_ENGINE=django.db.backends.postgresql_pyscopg2 >> .env
echo DATABASE=postgres >> .env
echo SECRET_KEY=${{ secrets.SECRET_KEY }} >> .env
echo SQL_DATABASE=${{ secrets.SQL_DATABASE }} >> .env
echo SQL_USER=${{ secrets.SQL_USER }} >> .env
echo SQL_PASSWORD=${{ secrets.SQL_PASSWORD }} >> .env
echo SQL_HOST=${{ secrets.SQL_HOST }} >> .env
echo SQL_PORT=${{ secrets.SQL_PORT }} >> .env
echo EMAIL_HOST=${{ secrets.EMAIL_HOST }} >> .env
echo EMAIL_PORT=${{ secrets.EMAIL_PORT }} >> .env
echo EMAIL_USE_TLS=${{ secrets.EMAIL_USE_TLS }} >> .env
echo EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }} >> .env
echo EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }} >> .env
echo DEFAULT_FROM_EMAIL=${{ secrets.DEFAULT_FROM_EMAIL }} .env
echo ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL=http://ventinghub.com/auth/sign-in
echo ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL=http://ventinghub.com/
echo SITE_ID=1
echo EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
echo redis_host=redis
- name: Add the private SSH key to the ssh-agent
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-add - <<< "${{ secrets.PRIVATE_KEY }}"
- name: Build and deploy images on DigitalOcean
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
scp -o StrictHostKeyChecking=no -r ./.env ./docker-compose.prod.yml root@${{ secrets.GCP_IP_ADDRESS }}:/app
ssh -o StrictHostKeyChecking=no goutambseervi@${{ secrets.GCP_IP_ADDRESS }} << 'ENDSSH'
cd /app
source .env
docker login docker.pkg.github.com -u Goutam192002 -p e0fa37cae6211ae1b908c57766e582b6628af519
docker pull $WEB_IMAGE
docker pull $CHANNELS_IMAGE
docker-compose -f docker-compose.prod.yml up -d
ENDSSH
Run Code Online (Sandbox Code Playgroud)
这里的错误是什么?过去 3 个小时我一直在挠头,我不知道。
我的猜测是您SECRET_KEY在运行步骤的第 4 行调用的秘密包含一个)字符。尝试用引号转义。
echo SECRET_KEY="${{ secrets.SECRET_KEY }}" >> .env
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
780 次 |
| 最近记录: |