From 4f07df81146fb51d85a845687be03c84c6834a79 Mon Sep 17 00:00:00 2001 From: Shunsuke KITADA Date: Tue, 25 Jun 2024 17:52:38 +0900 Subject: [PATCH] use makefile (#18) --- .github/workflows/layout_alignment.yaml | 18 +-------- .github/workflows/layout_average_iou.yaml | 18 +-------- .../layout_generative_model_scores.yaml | 18 +-------- .github/workflows/layout_maximum_iou.yaml | 18 +-------- .github/workflows/layout_overlap.yaml | 18 +-------- .github/workflows/layout_validity.yaml | 18 +-------- Makefile | 40 +++++++++++++++++++ 7 files changed, 46 insertions(+), 102 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/layout_alignment.yaml b/.github/workflows/layout_alignment.yaml index 244e00b..0a0b1c9 100644 --- a/.github/workflows/layout_alignment.yaml +++ b/.github/workflows/layout_alignment.yaml @@ -43,20 +43,4 @@ jobs: HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_EMAIL: ${{ secrets.HF_EMAIL }} run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + make deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/.github/workflows/layout_average_iou.yaml b/.github/workflows/layout_average_iou.yaml index 3c8b7bd..58b7275 100644 --- a/.github/workflows/layout_average_iou.yaml +++ b/.github/workflows/layout_average_iou.yaml @@ -43,20 +43,4 @@ jobs: HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_EMAIL: ${{ secrets.HF_EMAIL }} run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + make deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/.github/workflows/layout_generative_model_scores.yaml b/.github/workflows/layout_generative_model_scores.yaml index 9ea65c1..66b588d 100644 --- a/.github/workflows/layout_generative_model_scores.yaml +++ b/.github/workflows/layout_generative_model_scores.yaml @@ -43,20 +43,4 @@ jobs: HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_EMAIL: ${{ secrets.HF_EMAIL }} run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + make deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/.github/workflows/layout_maximum_iou.yaml b/.github/workflows/layout_maximum_iou.yaml index c4a26fc..3fd0cc7 100644 --- a/.github/workflows/layout_maximum_iou.yaml +++ b/.github/workflows/layout_maximum_iou.yaml @@ -43,20 +43,4 @@ jobs: HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_EMAIL: ${{ secrets.HF_EMAIL }} run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + make deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/.github/workflows/layout_overlap.yaml b/.github/workflows/layout_overlap.yaml index 9945d04..188b322 100644 --- a/.github/workflows/layout_overlap.yaml +++ b/.github/workflows/layout_overlap.yaml @@ -43,20 +43,4 @@ jobs: HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_EMAIL: ${{ secrets.HF_EMAIL }} run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + make deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/.github/workflows/layout_validity.yaml b/.github/workflows/layout_validity.yaml index b23858f..f5bc815 100644 --- a/.github/workflows/layout_validity.yaml +++ b/.github/workflows/layout_validity.yaml @@ -43,20 +43,4 @@ jobs: HF_USERNAME: ${{ secrets.HF_USERNAME }} HF_EMAIL: ${{ secrets.HF_EMAIL }} run: | - SCRIPT_NAME=${REPO_NAME}.py - - cp ${SRC_DIR}/${DIR_NAME}/README.md ${DST_DIR}/README.md - cp ${SRC_DIR}/${DIR_NAME}/${SCRIPT_NAME} ${DST_DIR}/${SCRIPT_NAME} - - git -C ${DST_DIR} config user.name "${HF_USERNAME}" - git -C ${DST_DIR} config user.email "${HF_EMAIL}" - - git -C ${DST_DIR} add README.md requirements.txt ${SCRIPT_NAME} - - if git -C ${DST_DIR} diff --cached --quiet; then - echo "No changes to commit" - else - msg=$(git -C ${SRC_DIR} rev-parse HEAD) - git -C ${DST_DIR} commit -m "deploy: ${msg}" - git -C ${DST_DIR} push -u origin main - fi + make deploy REPO_NAME=${REPO_NAME} DIR_NAME=${DIR_NAME} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2fdee47 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +SRC_DIR := ./github-repo +DST_DIR := ./huggingface-repo + +.PHONY: check-vars +check-vars: +ifndef ($(REPO_NAME),) + $(error REPO_NAME is not set) +endif + +ifndef ($(DIR_NAME),) + $(error DIR_NAME is not set) +endif + +ifndef ($(HF_USERNAME),) + $(error HF_USERNAME is not set) +endif + +ifndef ($(HF_EMAIL),) + $(error HF_EMAIL is not set) +endif + +.PHONY: deploy +deploy: check-vars + script_name=$(REPO_NAME).py + + cp $(SRC_DIR)/$(DIR_NAME)/README.md $(DST_DIR)/README.md + cp $(SRC_DIR)/$(DIR_NAME)/${script_name} $(DST_DIR)/${script_name} + + git -C $(DST_DIR) config user.name $(HF_USERNAME) + git -C $(DST_DIR) config user.email $(HF_EMAIL) + + git -C $(DST_DIR) add README.md requirements.txt ${script_name} + + if git -C $(DST_DIR) diff --cached --quiet; then + echo "No changes to commit" + else + msg=$(git -C $(SRC_DIR) rev-parse HEAD) + git -C $(DST_DIR) commit -m "deploy: ${msg}" + git -C $(DST_DIR) push -u origin main + fi