Skip to content

Commit

Permalink
cicd修正
Browse files Browse the repository at this point in the history
  • Loading branch information
nakagawa1022 committed Sep 18, 2024
1 parent 80ed783 commit 4b345db
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 42 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/touchgift-job-daemon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: touchgift-job-fluentd-daemon.yml
on:
pull_request:
branches:
- 'feature/**'
- 'beta/**'
- 'PB**'
paths:
- fluentd-daemon/**
push:
branches:
- 'feature/**'
- 'beta/**'
paths:
- fluentd-daemon/**
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
component:
- fluentd-daemon

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Configure AWS Credentials (CodeBuild)
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CODEBUILD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.CODEBUILD_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-1
role-to-assume: arn:aws:iam::411776208124:role/touchgift-job-fluentd-daemon.codebuild.execution
role-duration-seconds: 1200

- name: Run Build
run: |
aws codebuild start-build \
--project-name touchgift-job-fluentd-daemon \
--source-version ${SOURCE_VERSION} \
--buildspec-override ${{ matrix.component }}/buildspecs/staging.yml \
--environment-variables-override \
name=GITHUB_EVENT_NAME,value=${{ github.event_name }},type=PLAINTEXT \
name=GITHUB_SHA,value=${{ github.sha }},type=PLAINTEXT \
name=GITHUB_REF,value=${{ github.ref }},type=PLAINTEXT \
name=GITHUB_RUN_ID,value=${{ github.run_id }},type=PLAINTEXT \
name=WORKING_DIR,value=${{ matrix.component }},type=PLAINTEXT \
--report-build-status-override
env:
SOURCE_VERSION: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
2 changes: 1 addition & 1 deletion fluentd-daemon/buildspecs/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ phases:
- |
case "$GITHUB_REF" in
refs/heads/feature/*)
ENVIRONMENT_SUFFIX=e2
ENVIRONMENT_SUFFIX=e1
;;
refs/heads/beta/*)
ENVIRONMENT_SUFFIX=beta1
Expand Down
46 changes: 6 additions & 40 deletions manager/buildspecs/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,18 @@ version: 0.2

env:
variables:
UT_RESOURCE_PREFIX: UT_TOUCHGIFT_DDM
DB_DRIVER_NAME: mysql
DB_PORT: 3306
DB_USER: master
DB_CONNECT_TIMEOUT_SEC: 600
parameter-store:
DB_HOST: /rds/touchgift-cicd/endpoint
DB_PASSWORD: /rds/touchgift-cicd/user/master/password
MYSQL_PASSWORD: /rds/touchgift-cicd/user/master/password
UT_RESOURCE_PREFIX: UT

phases:
install:
runtime-versions:
golang: 1.20
commands:
- apt-get update -y
- apt-get install -y mysql-server-8.0
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
- go get -u github.com/jstemmer/go-junit-report
- goenv install -l
- goenv versions
- go version
- goenv install --list
- goenv install 1.20.6 || exit 0
- goenv global 1.20.6
- goenv rehash
- go version
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
pre_build:
commands:
- WEBHOOK_EVENT=$GITHUB_EVENT_NAME
Expand All @@ -42,28 +28,14 @@ phases:
esac
- echo "Config ENVIRONMENT_SUFFIX $ENVIRONMENT_SUFFIX"
- git status
- cd $CODEBUILD_SRC_DIR/$WORKING_DIR
- echo Create DynamoDB table...
- TN_PREFIX=${UT_RESOURCE_PREFIX}_${CODEBUILD_BUILD_NUMBER}_
- make create-all-table TN_PREFIX=${TN_PREFIX} DYNAMODB_OPTIONS=""
- echo "Create Database"
- DB_DATABASE="touchgift_delivery_data_manager_${CODEBUILD_BUILD_NUMBER}"
- mysql -h "${DB_HOST}" -u "${DB_USER}" -P "${DB_PORT}" -p${DB_PASSWORD} -e "CREATE DATABASE ${DB_DATABASE} TEMPLATE 'template0' ENCODING 'UTF8' LC_COLLATE 'ja_JP.UTF-8' LC_CTYPE 'ja_JP.UTF-8';" -p${MYSQL_PASSWORD}
- mysql -h "${DB_HOST}" -u "${DB_USER}" -p "${DB_PORT}" -p${DB_PASSWORD} {DB_DATABASE} < rdb/init/1_all.sql
- echo Logging in to Amazon ECR...
- IMAGE_TAG=$GITHUB_SHA
- cd $WORKING_DIR
- git init
- IMAGE_TAG=${GITHUB_SHA}.${GITHUB_RUN_ID}
build:
commands:
- aws --version
- echo "Build started on `date` $WEBHOOK_EVENT $GITHUB_REF"
- echo "GITHUB_EVENT_NAME $GITHUB_EVENT_NAME, GITHUB_SHA $GITHUB_SHA, GITHUB_REF $GITHUB_REF, GITHUB_RUN_ID $GITHUB_RUN_ID"
- make mod-tidy
- $(go env GOPATH)/bin/golangci-lint run --tests
- |
make test \
AWS_PROFILE="" \
DYNAMODB_ENDPOINT="" \
TABLE_NAME_PREFIX=${TN_PREFIX}
- echo Building the Docker image...
- make build-image TAG=$IMAGE_TAG AWS_VAULT_CMD=
- |
Expand All @@ -81,12 +53,6 @@ phases:
make push-image TAG=$IMAGE_TAG AWS_VAULT_CMD= && \
make run-deploy TAG=$IMAGE_TAG AWS_VAULT_CMD= ENV=staging ENVIRONMENT_SUFFIX=${ENVIRONMENT_SUFFIX}
fi
finally:
- echo finally ...
- echo Delete DynamoDB table...
- make delete-all-table TN_PREFIX=${TN_PREFIX} DYNAMODB_OPTIONS=""
- echo "Drop database"
- mysql -h "${DB_HOST}" -u "${DB_USER}" -P "${DB_PORT}" -e "DROP DATABASE ${DB_DATABASE}" -p
post_build:
commands:
- echo Build completed on `date`
1 change: 0 additions & 1 deletion manager/test

This file was deleted.

0 comments on commit 4b345db

Please sign in to comment.