[英]How to deploy and angular app using GitHubActions to EC2 with Yarn as the package manager?
I have written a yaml script with a help of a blog that contains all the necessary work that needs to be carried out in order to deploy my application to an ec2 instance running ubuntu. NGINX has been installed and is running.我在博客的帮助下编写了一个 yaml 脚本,其中包含将我的应用程序部署到运行 ubuntu 的 ec2 实例所需执行的所有必要工作。NGINX 已安装并正在运行。 Unfortunately, my yaml script fails silently, I do not know what is wrong, here is the code that's in the script
不幸的是,我的 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"
Can anyone point out what could be the issue here?谁能指出这里的问题是什么?
this is an example of workflow that build, test and deploy angular app to AWS S3:这是构建、测试 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
I just wanted to let you know that I ended up using Amplify, which was a lot easier.我只是想让你知道,我最终使用了 Amplify,这要容易得多。 At the end non of the recommended answers worked.
最后没有推荐的答案有效。 The linux ubuntu EC2 was still giving me issues.
linux ubuntu EC2 仍然给我带来问题。 It escalated to ng build not found but the environment had everything set so yaa.
它升级为 ng build not found 但环境已设置好一切,所以 yaa。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.