github - AWS CI/CD 与 GItHub 操作和代码部署到 EC2 实例
问题描述
我正在尝试使用 github 操作执行 ci/cd,并将 aws 代码部署到 ec2 实例。
我有一个 ec2 实例和三个 github 存储库(每个存储库也有自己的 gitflow)
name: Deployment
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
buildAndTest:
name: CI Pipeline
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ '14.x' ]
steps:
- uses: actions/checkout@v2
# Initialize Node.js
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Install project dependencies, test and build
- name: Install dependencies
run: yarn
- name: Run build
run: yarn build
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['14.x']
appname: ['app_name']
deploy-group: ['group_name']
region: ['region']
needs: [buildAndTest]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
# Initialize Node.js
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Step 1
- 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: ${{ matrix.region }}
# Step 2
- name: Create CodeDeploy Deployment
id: deploy
run: |
aws deploy create-deployment \
--application-name ${{ matrix.appname }} \
--deployment-group-name ${{ matrix.deploy-group }} \
--deployment-config-name CodeDeployDefault.OneAtATime \
--github-location repository=${{ github.repository }},commitId=${{ github.sha }}
当我向一个仓库推送或拉取请求时效果很好,但是当我一次推送两个仓库时,这意味着我要同时推送和部署,只有一个成功,另一个失败。
version: 0.0
os: linux
files:
- source: .
destination: /var/www/source
hooks:
ApplicationStart:
- location: deploy.sh // yarn install and restart server.
timeout: 300
runas: root
真正令人好奇的是,除了主要位置(在 ec2 中)之外,其他 repos(两个)中的一些文件(不包括 build 等)被删除了???我对三个存储库使用相同的应用程序和组 ID,这是一个问题吗?
任何帮助都会非常有帮助:)
解决方案
推荐阅读
- sql-server - 是否有 CREATE TABLE 或 CREATE PROCEDURE 自动确定 SSMS 中的列类型?
- amazon-web-services - AWS 中的多区域 Cassandra 仅在“nodetool 状态”上显示本地
- javascript - Why does two recaptcha appear at one moment in time?
- sql-server - 获取大于 SSRS 中当前日期的所有日期
- javascript - webpack.config 的问题
- awk - 创建包含总数和百分比的 bin
- java - 如何触发 Java 单元测试的 JsonProcessingException?
- string - 如何将此数字和符号列表转换为字符串?
- html - 为什么这种悬停效果会将旁边的其他元素推开?
- javascript - 使用 EmberJS 和 Oauth2,失效后如何修改默认路由?