-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Kubernetes changes #192
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb8be39
feat: add graceful shutdown
okan-cakmak 1be600a
ci: add docker-publish
okan-cakmak 5b7095d
fix: add response body to hc endpoint
okan-cakmak a92b721
fix: shutdown order
okan-cakmak cc42713
fix: httpterminator init
okan-cakmak 51a18b2
build: update axios
okan-cakmak e007c5c
refactor: improve naming
okan-cakmak ca3772b
fix: leftover env
okan-cakmak 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 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,134 @@ | ||
on: | ||
workflow_run: | ||
workflows: | ||
- "Check Code Quality" | ||
branches: | ||
- main | ||
types: | ||
- completed | ||
|
||
name: Build and Push to ECR | ||
|
||
jobs: | ||
build-and-push: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
name: Build and Push | ||
environment: ${{ startsWith(github.ref, 'refs/tags/') && 'prod' || 'dev' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.get-version.outputs.version }} | ||
commit: ${{ steps.get-commit-id.outputs.commit }} | ||
environment: ${{ steps.set-environment.outputs.environment }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Configure Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 16.13 | ||
registry-url: 'https://npm.pkg.github.com' | ||
scope: '@zeplin' | ||
cache: 'npm' | ||
|
||
- id: get-commit-id | ||
name: Get commit id | ||
run: echo "commit=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT | ||
|
||
- name: Create revision file | ||
run: echo $(date +%s)-${{ steps.get-commit-id.outputs.commit }} >./revision.txt | ||
|
||
- id: get-version | ||
name: Get version | ||
run: echo "version=${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }}" >> $GITHUB_OUTPUT | ||
|
||
- name: Set package version | ||
if: ${{ steps.get-version.outputs.version }} # ${GITHUB_REF} does not have a tag if this is not set above | ||
run: npm version ${GITHUB_REF#refs/tags/v} --no-git-tag-version --allow-same-version | ||
|
||
- id: set-environment | ||
name: Set environment | ||
run: echo "environment=${{ startsWith(github.ref, 'refs/tags/') && 'prod' || 'dev' }}" >> $GITHUB_OUTPUT | ||
|
||
- name: Install all dependencies | ||
run: npm ci --ignore-scripts | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
|
||
- name: Run post install scripts of dependencies | ||
run: npm rebuild && npm run prepare --if-present | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Install dependencies without devDependencies | ||
run: npm ci --omit=dev --ignore-scripts | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
|
||
- name: Run post install scripts of dependencies | ||
run: npm rebuild && npm run prepare --if-present | ||
|
||
- name: Build and push Docker image to AWS ECR | ||
run: | | ||
REPO="${{ vars.AWS_ACCOUNT_ID || '915497967985' }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com" | ||
IMAGE="$REPO/microsoft-teams-app:${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || steps.get-commit-id.outputs.commit }}" | ||
IMAGE_WITH_ENV_TAG="$REPO/microsoft-teams-app:${{ steps.set-environment.outputs.environment }}" | ||
docker build -t $IMAGE . | ||
docker tag $IMAGE $IMAGE_WITH_ENV_TAG | ||
aws ecr get-login-password --region ${{ vars.AWS_REGION }} | docker login --username AWS --password-stdin $REPO | ||
docker push $IMAGE | ||
docker push $IMAGE_WITH_ENV_TAG | ||
|
||
- name: Trigger infra workflow to deploy new image version | ||
run: | | ||
JSON_DATA=$( | ||
jq -n -c \ | ||
--arg b "${{ github.ref_name }}" \ | ||
--arg t "${{ github.ref_name }}" \ | ||
--arg v "${{ steps.get-version.outputs.version }}" \ | ||
--arg c "${{ steps.get-commit-id.outputs.commit }}" \ | ||
--arg e "${{ steps.set-environment.outputs.environment }}" \ | ||
'{"app-name": "microsoft-teams-app", "branch": $b, "version": $v, "tag": $t, "commit-id": $c, "environment": $e }' | ||
) | ||
echo $JSON_DATA | gh workflow run deploy-app.yaml --repo zeplin/infra --json | ||
echo "Workflow is triggered: https://github.com/zeplin/infra/actions/workflows/deploy-app.yaml" | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | ||
|
||
post-deploy: | ||
needs: build-and-push | ||
name: Post Deploy Actions | ||
environment: ${{ needs.build-and-push.outputs.environment }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create New Relic deployment marker | ||
uses: newrelic/[email protected] | ||
with: | ||
apiKey: ${{ secrets.NEWRELIC_API_KEY }} | ||
guid: ${{ vars.NEWRELIC_APPLICATION_GUID }} | ||
version: ${{ needs.build-and-push.outputs.version || needs.build-and-push.outputs.commit }} | ||
commit: ${{ needs.build-and-push.outputs.commit }} | ||
groupId: ${{ startsWith(github.ref, 'refs/tags/') && 'prod' || github.ref_name }} | ||
|
||
- name: Create Sentry release | ||
uses: getsentry/action-release@v1 | ||
env: | ||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | ||
SENTRY_ORG: zeplin | ||
SENTRY_PROJECT: microsoft-teams-app | ||
with: | ||
environment: ${{ needs.build-and-push.outputs.environment }} | ||
version: ${{ needs.build-and-push.outputs.version }} |
This file contains 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,13 @@ | ||
FROM node:v16.13.0 | ||
RUN apt-get update && apt-get install tini | ||
RUN npm install pm2 -g | ||
|
||
ENV APP_HOME="/usr/src/app" | ||
|
||
WORKDIR ${APP_HOME} | ||
|
||
COPY . ${APP_HOME}/ | ||
|
||
ENTRYPOINT ["tini", "--"] | ||
|
||
CMD ["pm2-runtime", "pm2.json"] |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I see, this is similar to scim. Can you remind me why we need these in this file? I mean this could be a dev publish. (@yuqu)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a dev publish it will just create release markers on Newrelic and Sentry for dev environment, we won't see it for prod environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newrelic shows "related changes" as markers, I'd definitely not want to see it as a related change in its prod version, for example.
Also, the reason I was confused was because I forgot we'll get rid off
development.yaml
andproduction.yaml
files. We should check if the new docker publish does everything in those files in other services, too (for example public-api does not put markets in the docker publish file).