Skip to content

Commit

Permalink
feat: git actions
Browse files Browse the repository at this point in the history
  • Loading branch information
wlstmd committed Jul 16, 2024
1 parent 64a1dac commit 2e540af
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
dist
23 changes: 23 additions & 0 deletions .github/workflows/git-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Docker Image CI

on:
push:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login Dockerhub
env:
DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}}

run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- name: Build the Docker image
run: docker build -t registar .
- name: taging
run: docker tag registar:latest jinseung0327/registar:latest
- name: Push to Dockerhub
run: docker push jinseung0327/registar:latest
34 changes: 34 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CD Pipeline

on:
workflow_run:
workflows: ['Docker Image CI']
types:
- completed

jobs:
build:
runs-on: self-hosted

steps:
- name: Pull Docker image
run: sudo docker pull jinseung0327/registar:latest

- name: Delete Old docker container
run: sudo docker rm -f registar || true

- name: Run Docker Container
env:
CLIENT_ID: ${{secrets.CLIENT_ID}}
CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}}
ALLOWED_IP: ${{secrets.ALLOWED_IP}}
SERVER_URL: ${{secrets.SERVER_URL}}
run: |
sudo docker run -d
-e CLIENT_ID=$CLIENT_ID \
-e CLIENT_SECRET=$CLIENT_SECRET \
-e ACCESS_TOKEN=$ACCESS_TOKEN \
-e ALLOWED_IP=$ALLOWED_IP \
-e SERVER_URL=$SERVER_URL \
-p 3000:3000 --name registar jinseung0327/registar
2 changes: 1 addition & 1 deletion src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class AuthController {
);
}
const serverUrl = this.configService.get<string>('SERVER_URL');
const clientId = this.configService.get('GITHUB_CLIENT_ID');
const clientId = this.configService.get('CLIENT_ID');
const redirectUri = encodeURIComponent(`${serverUrl}/auth/github/callback`);
const githubAuthUrl = `https://github.com/login/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}`;
return res.redirect(githubAuthUrl);
Expand Down
6 changes: 3 additions & 3 deletions src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export class AuthService {
.useBasicHeaders()
.useGetAccessTokenEndpoint()
.useJSONPostBody({
client_id: this.configService.get('GITHUB_CLIENT_ID'),
client_secret: this.configService.get('GITHUB_CLIENT_SECRET'),
client_id: this.configService.get('CLIENT_ID'),
client_secret: this.configService.get('CLIENT_SECRET'),
code,
})
.getFetcher()
Expand All @@ -36,7 +36,7 @@ export class AuthService {
await new FetcherProxy()
.useBasicHeaders()
.useCreateInvitationEndpoint()
.useAPITokenAuthorization(this.configService.get('GITHUB_ACCESS_TOKEN')!)
.useAPITokenAuthorization(this.configService.get('ACCESS_TOKEN')!)
.useJSONPostBody({
invitee_id: userId,
role: 'admin',
Expand Down
6 changes: 3 additions & 3 deletions src/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default () => ({
CLIENT_ID: process.env.CLIENT_ID,
GITHUB_CLIENT_SECRET: process.env.GITHUB_CLIENT_SECRET,
GITHUB_ACCESS_TOKEN: process.env.GITHUB_ACCESS_TOKEN,
GITHUB_ORG_NAME: process.env.GITHUB_ORG_NAME,
CLIENT_SECRET: process.env.CLIENT_SECRET,
ACCESS_TOKEN: process.env.ACCESS_TOKEN,
ALLOWED_IP: process.env.ALLOWED_IP,
SERVER_URL: process.env.SERVER_URL,
});

0 comments on commit 2e540af

Please sign in to comment.