├── .github
│ └── workflows
│ ├── cd.yml
│ └── ci.yml
├── scripts
│ ├── createDevEBAppVersion.sh
│ └── createProdEBAppVersion.sh
├── src
Github Actions 抛出以下错误:
/home/runner/work/_temp/9c99fa0d-20da-49ed-a0af-322f274c13ac.sh: 第1行:[refs/heads/develop: 没有那个文件或目录
/home/runner/work/_temp/9c99fa0d-20da-49ed-a0af-322f274c13ac.sh: 第5行:[[refs/heads/develop: 没有那个文件或目录
name: CD
env:
PACKAGE_NAME : "app_${GITHUB_SHA::8}.zip"
ARTIFACT_ROOT : "${GITHUB_REF#refs/*/}"
APPLICATION_NAME : "example-app-name"
AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_KEY }}
AWS_REGION : ${{ secrets.AWS_REGION }}
AWS_BUCKET : ${{ secrets.AWS_S3_BUCKET_NAME }}
on:
push:
branches:
- develop
paths-ignore:
- '**.json'
- '**.md'
release:
tags:
- 'v*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create ZIP package artifact
run: git archive --format=zip HEAD -o ${{ env.PACKAGE_NAME }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Copy package artifact to S3 bucket
run: |
aws s3 cp ${{ env.PACKAGE_NAME }} s3://${{ env.AWS_BUCKET }}/${{ env.APPLICATION_NAME }}/
echo "✔ Artifact uploaded successfully to s3://${{ env.AWS_BUCKET }}/${{ env.APPLICATION_NAME }}/${{ env.PACKAGE_NAME }}"
- name: Create new ElasticBeanstalk Application Version
working-directory: scripts
run : |
if ["${{ github.ref }}" == "refs/heads/develop"]; then
chmod +x ./createDevEBAppVersion.sh
./createDevEBAppVersion.sh
fi
if [["${{ github.ref }}" == *"refs/tags/v"*]]; then
chmod +x ./createProdEBAppVersion.sh
./createProdEBAppVersion.sh
fi
...
我曾尝试过没有working-directory
,但它并没有起作用。
#!/usr/bin/env bash
aws elasticbeanstalk create-application-version \
--application-name ${{ env.APPLICATION_NAME }} \
--source-bundle S3Bucket="${{ env.AWS_BUCKET }}",S3Key="${{ env.APPLICATION_NAME }}/${{ env.PACKAGE_NAME }}" \
--version-label "${{ env.PACKAGE_NAME }}" \
--description "Application version created from https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo "✔ Deployment triggered successfully."
看起来 CI 在寻找文件时出了问题。我如何执行 createDevEBAppVersion.sh
?
working-directory: scripts
吗? - JeffMinsungKim./createProdEBAppVersion.sh
。 您也可以运行scripts/createProdEBAppVersion.sh
并省略working-directory
。 - Edward Thomson