gpt4 book ai didi

github-actions - GitHub 操作失败 : syntax error near unexpected token `)'

转载 作者:行者123 更新时间:2023-12-04 15:59:33 26 4
gpt4 key购买 nike

我正在尝试实现 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: line 4: syntax error near unexpected token `)'



error log
我真的无法弄清楚这里出了什么问题。
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

这里的错误是什么?过去 3 个小时我一直在挠头,但我一无所知。

最佳答案

我猜你的 secret 叫SECRET_KEY在运行步骤的第 4 行包含一个 )特点。尝试用引号转义。

echo SECRET_KEY="${{ secrets.SECRET_KEY }}" >> .env

关于github-actions - GitHub 操作失败 : syntax error near unexpected token `)' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61795201/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com