Skip to content

Commit

Permalink
Merge pull request #66 from gdsc-ssu/feat/issue64
Browse files Browse the repository at this point in the history
Feat/issue64
  • Loading branch information
thinkjin99 authored Jul 28, 2024
2 parents a48de82 + 9a109c3 commit f492813
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/obs3dian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Process Markdown Files with Obs3dian

on:
push:
branches:
- main
paths:
- '**.md'


jobs:
install:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install obs3dian
- 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: ${{ secrets.AWS_REGION }}

- name: Run Python script
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
python3 config.py
- name: Process Markdown files
run: |
obs3dian apply --usekey
obs3dian run . --overwrite --usekey
- name: Commit changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Processed Markdown files using obs3dian" || echo "No changes to commit"
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
34 changes: 34 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import json
import os
from pathlib import Path

APP_NAME = "obs3dian"
SETUP_FILE_NAME = "config.json"
APP_DIR_PATH = "/home/runner/.config/obs3dian"


def save_config():
app_dir_path = Path(APP_DIR_PATH) # create app setting folder
aws_access_key_id = os.getenv("AWS_ACCESS_KEY_ID")
aws_secret_access_key = os.getenv("AWS_SECRET_ACCESS_KEY")
json_data = {
"profile_name": "default",
"aws_access_key": aws_access_key_id,
"aws_secret_key": aws_secret_access_key,
"bucket_name": "csocrates-s3",
"output_folder_path": "./output",
"image_folder_path": "./",
}

if not app_dir_path.exists():
app_dir_path.mkdir()

config_path = app_dir_path / SETUP_FILE_NAME
with config_path.open("w") as f:
json.dump(json_data, f) # write config.json

print(f"save config file in {config_path}")


if __name__ == "__main__":
save_config()

0 comments on commit f492813

Please sign in to comment.