-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from azuki774/add-s3-upload
s3 upload機能を追加
- Loading branch information
Showing
31 changed files
with
199 additions
and
732 deletions.
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
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 @@ | ||
name: Build test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
- name: Build images | ||
run: make build |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
FROM ghcr.io/azuki774/selenium-chrome:0.2.0 | ||
|
||
# Required Packages | ||
RUN apt-get update && \ | ||
apt-get install -y curl unzip && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# AWS Setup | ||
RUN curl -o /var/tmp/awscli.zip https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip && \ | ||
unzip -d /usr/local/bin/ /var/tmp/awscli.zip | ||
|
||
COPY requirements/ /tmp/ | ||
RUN pip install --upgrade pip && pip install -r /tmp/moneyforward_requirements.txt | ||
COPY --chmod=755 build/money-forward/main.sh /src/main.sh | ||
COPY src/moneyforward/ /src/ | ||
|
||
ENTRYPOINT ["/src/main.sh"] |
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,57 @@ | ||
#!/bin/bash | ||
set -e | ||
YYYYMM=`date '+%Y%m'` | ||
YYYYMMDD=`date '+%Y%m%d'` | ||
|
||
# BUCKET_URL # from env (ex: "https://s3.ap-northeast-1.wasabisys.com") | ||
# BUCKET_NAME # from env (ex: hoge-system-stg-bucket) | ||
# BUCKET_DIR # from env (ex: fetcher/money-forward) | ||
# AWS_REGION # from env (ex: ap-northeast-1) | ||
# AWS_ACCESS_KEY_ID # from env | ||
# AWS_SECRET_ACCESS_KEY # from env | ||
|
||
AWS_BIN="/usr/local/bin/aws/dist/aws" | ||
DATA_DIR="/data" | ||
|
||
REMOTE_DIR_DAILY="${BUCKET_DIR}/${YYYYMMDD}" | ||
REMOTE_DIR_LATEST="${BUCKET_DIR}/latest" | ||
|
||
function fetch () { | ||
echo "fetcher start" | ||
python3 -u /src/main.py | ||
echo "fetcher complete" | ||
} | ||
|
||
function create_s3_credentials { | ||
echo "s3 credentials create start" | ||
mkdir -p ~/.aws/ | ||
|
||
echo "[default]" >> ~/.aws/config | ||
echo "region = ${AWS_REGION}" >> ~/.aws/config | ||
|
||
echo "[default]" >> ~/.aws/credentials | ||
echo "aws_access_key_id = ${AWS_ACCESS_KEY_ID}" >> ~/.aws/credentials | ||
echo "aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" >> ~/.aws/credentials | ||
|
||
chmod 400 ~/.aws/config | ||
chmod 400 ~/.aws/credentials | ||
ls -la ~/.aws/ | ||
echo "s3 credentials create complete" | ||
} | ||
|
||
function s3_upload () { | ||
echo "s3 upload start" | ||
${AWS_BIN} s3 cp ${DATA_DIR}/${YYYYMMDD}/ "s3://${BUCKET_NAME}/${REMOTE_DIR_DAILY}" --recursive --endpoint-url="${BUCKET_URL}" | ||
mv ${DATA_DIR}/${YYYYMMDD} ${DATA_DIR}/latest | ||
${AWS_BIN} s3 cp ${DATA_DIR}/latest/ "s3://${BUCKET_NAME}/${REMOTE_DIR_LATEST}" --recursive --endpoint-url="${BUCKET_URL}" | ||
echo "s3 upload complete" | ||
} | ||
|
||
fetch | ||
|
||
if [ -z $BUCKET_NAME ]; then | ||
exit 0 | ||
fi | ||
|
||
create_s3_credentials | ||
s3_upload |
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,18 @@ | ||
FROM ghcr.io/azuki774/selenium-chrome:0.2.0 | ||
|
||
# Required Packages | ||
RUN apt-get update && \ | ||
apt-get install -y curl unzip && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# AWS Setup | ||
RUN curl -o /var/tmp/awscli.zip https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip && \ | ||
unzip -d /usr/local/bin/ /var/tmp/awscli.zip | ||
|
||
COPY requirements/ /tmp/ | ||
RUN pip install --upgrade pip && pip install -r /tmp/sbi_requirements.txt | ||
COPY --chmod=755 build/sbi/main.sh /src/main.sh | ||
COPY src/sbi/ /src/ | ||
|
||
ENTRYPOINT ["/src/main.sh"] |
Oops, something went wrong.