-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: ci cd setup #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
98ca4ac
fix: parameter names and cron schedule
GoGiants1 4ffea26
fix: cron parameter
GoGiants1 de4f98c
build: add Dockerfile
GoGiants1 d206aad
build: add github ci/cd for crawler
GoGiants1 f0d51ef
chore: add db port env
GoGiants1 a086e37
fix: target branch of dev ci/cd
GoGiants1 bf06150
fix
GoGiants1 2079fe0
fix: add newline
GoGiants1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Upload image to ECR DEV | ||
on: | ||
push: | ||
branches: ["dev"] | ||
env: | ||
AWS_REGION: ap-northeast-2 # set this to your preferred AWS region, e.g. us-west-1 | ||
ECR_REPOSITORY_K8S: siksha-dev/siksha-crawler | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
name: deploy dev | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- 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: Get current date | ||
id: date | ||
run: echo "::set-output name=date::$(date '+%Y-%m-%d-%H-%M-%S')" | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: FOR K8S) Build, tag, and push image to Amazon ECR | ||
id: build-image-k8s | ||
env: | ||
IMAGE_TAG: ${{ github.run_number }} | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
run: | | ||
# Build a docker container and | ||
# push it to ECR so that it can | ||
# be deployed to ECS. | ||
docker build --platform linux/amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY_K8S:$IMAGE_TAG . \ | ||
--build-arg DB_HOST=${{ secrets.DB_HOST }} \ | ||
--build-arg DB_NAME=${{ secrets.DB_NAME_DEV }} \ | ||
--build-arg DB_USER=${{ secrets.DB_USER_DEV }} \ | ||
--build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD_DEV }} \ | ||
--build-arg SLACK_TOKEN=${{ secrets.SLACK_TOKEN }} \ | ||
--build-arg SLACK_CHANNEL=${{ secrets.SLACK_CHANNEL_DEV }} | ||
|
||
docker push $ECR_REGISTRY/$ECR_REPOSITORY_K8S:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY_K8S:$IMAGE_TAG" >> $GITHUB_OUTPUT | ||
GoGiants1 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Upload image to ECR PROD | ||
on: | ||
push: | ||
branches: ["prod"] | ||
env: | ||
AWS_REGION: ap-northeast-2 # set this to your preferred AWS region, e.g. us-west-1 | ||
ECR_REPOSITORY_K8S: siksha-prod/siksha-crawler | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
name: deploy prod | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- 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: Get current date | ||
id: date | ||
run: echo "::set-output name=date::$(date '+%Y-%m-%d-%H-%M-%S')" | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: FOR K8S) Build, tag, and push image to Amazon ECR | ||
id: build-image-k8s | ||
env: | ||
IMAGE_TAG: ${{ github.run_number }} | ||
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
run: | | ||
# Build a docker container and | ||
# push it to ECR so that it can | ||
# be deployed to ECS. | ||
docker build --platform linux/amd64 -t $ECR_REGISTRY/$ECR_REPOSITORY_K8S:$IMAGE_TAG . \ | ||
--build-arg DB_HOST=${{ secrets.DB_HOST }} \ | ||
--build-arg DB_NAME=${{ secrets.DB_NAME }} \ | ||
--build-arg DB_USER=${{ secrets.DB_USER }} \ | ||
--build-arg DB_PASSWORD=${{ secrets.DB_PASSWORD }} \ | ||
--build-arg SLACK_TOKEN=${{ secrets.SLACK_TOKEN }} \ | ||
--build-arg SLACK_CHANNEL=${{ secrets.SLACK_CHANNEL }} | ||
|
||
docker push $ECR_REGISTRY/$ECR_REPOSITORY_K8S:$IMAGE_TAG | ||
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY_K8S:$IMAGE_TAG" >> $GITHUB_OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM python:3.10 | ||
|
||
ARG DB_HOST | ||
ARG DB_NAME | ||
ARG DB_USER | ||
ARG DB_PASSWORD | ||
ARG SLACK_TOKEN | ||
ARG SLACK_CHANNEL | ||
|
||
ENV DB_HOST $DB_HOST | ||
ENV DB_PORT 3306 | ||
ENV DB_NAME $DB_NAME | ||
ENV DB_USER $DB_USER | ||
ENV DB_PASSWORD $DB_PASSWORD | ||
ENV SLACK_TOKEN $SLACK_TOKEN | ||
ENV SLACK_CHANNEL $SLACK_CHANNEL | ||
|
||
COPY . /siksha-crawler | ||
WORKDIR /siksha-crawler | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN pip install --upgrade pip | ||
RUN pip install -r requirements.txt | ||
|
||
CMD ["python", "handler.py"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.