Skip to content

Commit

Permalink
Merge branch 'master' into auto-push
Browse files Browse the repository at this point in the history
  • Loading branch information
Sniij committed Jan 5, 2025
2 parents c7da991 + 193763f commit 7029901
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/convert-to-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
pull_request:
branches:
- convert-markdown

defaults:
run:
working-directory: ./convert-to-markdown
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/crawling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
pull_request:
branches:
- crawling

defaults:
run:
working-directory: ./crawling
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/gpt-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
pull_request:
branches:
- gpt-api

defaults:
run:
working-directory: ./gpt-api
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/upload-to-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
pull_request:
branches:
- upload-to-github

defaults:
run:
working-directory: ./upload-to-github
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -37,7 +39,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
LAMBDA_FUNCTION_NAME: ${{ secrets.UPLOAD_GITHUB_LAMBDA_FUNCTION_NAME }}
AWS_REGION: ${{ secrets.AWS_REGION }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
TOKEN_GITHUB: ${{ secrets.TOKEN_GITHUB }}
OWNER_GITHUB: ${{ secrets.OWNER_GITHUB }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/upload-to-s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:
pull_request:
branches:
- upload-to-s3

defaults:
run:
working-directory: ./upload-to-s3
jobs:
deploy:
runs-on: ubuntu-latest
Expand Down
6 changes: 1 addition & 5 deletions upload-to-github/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"golang.org/x/oauth2"
)

// S3Downloader downloads files from S3
type S3Downloader struct {
Client *s3.Client
BucketName string
Expand All @@ -40,7 +39,6 @@ func main() {
lambda.Start(Handler)
}

// ListFiles lists all files in a specific S3 path
func (d *S3Downloader) ListFiles(ctx context.Context, prefix string) ([]string, error) {
var files []string
paginator := s3.NewListObjectsV2Paginator(d.Client, &s3.ListObjectsV2Input{
Expand All @@ -62,7 +60,6 @@ func (d *S3Downloader) ListFiles(ctx context.Context, prefix string) ([]string,
return files, nil
}

// DownloadFile downloads a file from S3
func (d *S3Downloader) DownloadFile(ctx context.Context, key string) ([]byte, error) {
output, err := d.Client.GetObject(ctx, &s3.GetObjectInput{
Bucket: aws.String(d.BucketName),
Expand All @@ -82,14 +79,12 @@ func (d *S3Downloader) DownloadFile(ctx context.Context, key string) ([]byte, er
return buf.Bytes(), nil
}

// GitHubUploader uploads files to GitHub
type GitHubUploader struct {
Client *github.Client
Owner string
Repo string
}

// UploadFiles uploads multiple files to GitHub in a single commit
func (u *GitHubUploader) UploadFiles(ctx context.Context, files map[string][]byte, commitMessage string) error {
// Get the reference to the HEAD of the default branch (e.g., main)
ref, _, err := u.Client.Git.GetRef(ctx, u.Owner, u.Repo, "heads/main")
Expand Down Expand Up @@ -180,6 +175,7 @@ func (u *GitHubUploader) UploadFile(ctx context.Context, path string, content []

return nil
}

func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {

// 1. 환경 변수 불러오기
Expand Down

0 comments on commit 7029901

Please sign in to comment.