如何部署和使用GitHubActions到EC2与Yarn作为包管理器角应用程序?



我在一个博客的帮助下写了一个yaml脚本,其中包含了为了将我的应用程序部署到运行ubuntu的ec2实例而需要进行的所有必要的工作。NGINX已安装并正在运行。不幸的是,我的yaml脚本无声地失败了,我不知道出了什么问题,这里是脚本

中的代码
name: CI
on:
push:
branches: [main]
pull_request: 
branches: [main]
jobs:
build:
# using Ubuntu
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Run install
uses: borales/actions-yarn@v4 
with:
cmd: install
- name: Install Angular CLI
uses: borales/actions-yarn@v4
with:
cmd: yarn global add @angular/cli
- name: Build production bundle
uses: borales/actions-yarn@v4
with:
cmd: build:prod # will run `yarn build:prod` command
- name: Deploy to my EC2 instance
uses: easingthems/ssh/deploy@2.1.5
with: 
SSH_PRIVATE_KEY: $ {{ secrets.SSH_PRIVATE_KEY }} # I have the SSH_Private key of the instance saved as secrets in GitHub under the repository settings.
SOURCE: "dist/my-client-app"
REMOTE_HOST: "my-remote-host" # here I used my instances's IP Address. Not sure if that is what I am supposed to put there.
REMOTE_USER: "ubuntu"
TARGET: "/var/www/html/my-client-app"

谁能指出这里的问题是什么?

这是一个构建、测试和部署angular应用到AWS S3的工作流示例:

jobs:
build-test-deploy:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm install
- name: test # this section runs tests
run: npm run test
- name: Build
run: npm run build
- name: Deploy
if: success()
run: aws s3 sync ./dist/app/ s3://your-bucket-name

我只是想让你知道我最终使用了Amplify,这更容易。最后,推荐的答案都不起作用。linux ubuntu EC2仍然会给我一些问题。它升级到ng build not found,但是环境已经设置好了。

最新更新