我正在尝试使用GitHub操作设置部署。构建React应用程序并使用快递服务。
name: EB Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install awsebcli
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Deploy to Elastic Beanstalk
run: |
cd client
npm i
npm run build
mv dist ..
cd ..
eb deploy
app.use(express.static(path.join(__dirname, './dist')))
除了eb
没有部署dist
文件夹外,其他一切都很好。
即使当我运行eb labs download
下载部署的版本时,我在zip文件中也看不到dist
文件夹。
我最终压缩了整个目录并eb deploy --staged
它,以便它工作。
我猜eb
忽略了dist
文件夹,因为它没有被git跟踪。我添加了以下命令:
git config --global user.email "GH-DEPLOY@aws.null"
git config --global user.name "GH-DEPLOY"
git add dist
git commit -m 'add react app'
eb deploy --staged