общий репозиторий, в котором есть папки с сайтами.- это называется monorepo.
name: GitHub Actions Demo
on:
push:
paths:
- 'akado/**'
jobs:
init:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Starting Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: install modules
run: npm install
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: build project
run: npm run build
name: Build
on:
workflow_call:
jobs:
init:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Starting Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: install modules
run: npm install
- name: cache dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: build project
run: npm run build
name: Akado
on:
workflow_dispatch:
push:
jobs:
build:
- uses: Tarifnik/react-app/.github/workflows/buildAndPublish.yml
name: Build
on:
workflow_call:
inputs:
path: string
jobs:
init:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./${{ inputs.path }}
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Starting Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: install modules
run: npm install --legacy-peer-deps
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.npm
${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: build project
run: npm run build
name: buildAkado
on:
workflow_dispatch:
push:
paths:
- 'akado/**'
jobs:
build:
- uses: Tarifnik/react-app/.github/workflows/build.yml
name: Reusable workflow for build / push / deploy
on:
workflow_call:
inputs:
SERVICE_NAME:
type: string
required: true
DIR_NAME:
type: string
required: true
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
SLACK_BOT_TOKEN:
required: true
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: server-${{ inputs.SERVICE_NAME }}
ECR_REGISTRY: xxxxx
IMAGE_TAG: ${{ github.sha }}
SERVICE_NAME: ${{ inputs.SERVICE_NAME }}
DIR_NAME: ${{ inputs.DIR_NAME }}
jobs:
build_push_deploy:
name: BuildPushDeploy
runs-on: ubuntu-latest
timeout-minutes: 12
steps:
- name: print env
run: env
- name: set environment (staging)
if: github.ref_name == 'staging'
run: |
echo "branch is staging"
echo "ECS_SERVICE= ${{ env.SERVICE_NAME }}-server" >> $GITHUB_ENV
echo "ECS_CLUSTER= staging-cluster" >> $GITHUB_ENV
echo "ECS_TASK_DEFINITION=fffff.${{ env.DIR_NAME }}/${{ env.SERVICE_NAME }}-server-staging-task-definition.json" >> $GITHUB_ENV
echo "CONTAINER_NAME= ${{ env.SERVICE_NAME }}-server" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- 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: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -f ffff.${{ env.DIR_NAME }}/Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
- name: Notify slack
if: always()
uses: voxmedia/github-action-slack-notify-build@v1
with:
channel_id: cccccccc
status: ${{ job.status }}
color: ${{ job.status == 'success' && 'good' || 'danger' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
STATUS: ${{ job.status }}
on:
push:
branches: [master,staging,sandbox]
paths:
- 'fff.ooo/**'
- '.github/workflows/ooo_build_push_ecr_deploy_ecs.yml'
- '.github/workflows/workflow_build_push_ecr_deploy_ecs.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: xxxxx
ECR_REGISTRY: xxxxxxx
IMAGE_TAG: ${{ github.sha }}
name: Orders> build Docker image, push to ECR, deploy to ECS
jobs:
build_push_deploy:
uses: ./.github/workflows/workflow_build_push_ecr_deploy_ecs.yml
with:
DIR_NAME: "ooooo"
SERVICE_NAME: "oooo"
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
on:
workflow_call:
inputs:
path:
required: true
type: string
defaults:
run:
working-directory: ./${{ inputs.path }}
name: build_akado
on:
push:
paths:
- 'akado/**'
pull_request:
paths:
- 'akado/**'
jobs:
build:
uses: ./.github/workflows/build.yml
with:
path: akado