From 2aac4bfca50cf31e7cbec2e8a6c84c014cfb35fb Mon Sep 17 00:00:00 2001 From: gradedSystem Date: Sun, 6 Oct 2024 23:18:54 +0700 Subject: [PATCH 1/3] [add][m] Adding github workflow --- .github/workflows/actions.yml | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/actions.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml new file mode 100644 index 0000000000..8917f885cb --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,65 @@ +name: Run Makefile with Selenium + +on: + # Schedule to run on the 1st day of each month + schedule: + - cron: '0 0 1 * *' + + # Run on push to master branch + push: + branches: + - main + + # Run on pull requests targeting the master branch + pull_request: + branches: + - main + + # Allows manual triggering of the workflow + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + if: github.ref == 'refs/heads/main' + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install Python dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install --upgrade pip + pip install -r scripts/requirements.txt + + - name: Run data generation script + run: | + source venv/bin/activate + python scripts/data_generate.py + + - name: Run table generation script + run: | + source venv/bin/activate + python scripts/table_generate.py + + - name: Push and Commit + env: + CI_COMMIT_NAME: "Automated commit" + CI_COMMIT_EMAIL: "actions@users.noreply.github.com" + CI_COMMIT_MESSAGE: "Automated commit" + run: | + git config --global user.email "${{env.CI_COMMIT_EMAIL}}" + git config --global user.name "${{env.CI_COMMIT_NAME}}" + git diff --quiet && echo "No changes to commit" || ( + git add data/ && + git commit -m "${{env.CI_COMMIT_MESSAGE}}" && + git push origin main # Specify the branch + ) \ No newline at end of file From fe47c1ca77031fb44f39c7405dd9d4b4666a1cdb Mon Sep 17 00:00:00 2001 From: gradedSystem Date: Wed, 23 Oct 2024 18:03:00 +0700 Subject: [PATCH 2/3] [update][m] From Push job to Pull request / minor fixes --- .github/workflows/actions.yml | 40 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 8917f885cb..6bbf5ad633 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,21 +1,18 @@ -name: Run Makefile with Selenium +name: UNLOCODE Data Processing on: # Schedule to run on the 1st day of each month schedule: - cron: '0 0 1 * *' - # Run on push to master branch push: branches: - main - # Run on pull requests targeting the master branch pull_request: branches: - main - # Allows manual triggering of the workflow workflow_dispatch: jobs: @@ -40,26 +37,27 @@ jobs: pip install --upgrade pip pip install -r scripts/requirements.txt - - name: Run data generation script + - name: Install other tools (e.g., mdbtools, csvkit) + run: | + sudo apt-get update + sudo apt-get install -y mdbtools csvkit + + - name: Run Makefile run: | source venv/bin/activate - python scripts/data_generate.py + make - - name: Run table generation script + - name: Clean from .zip files run: | source venv/bin/activate - python scripts/table_generate.py + make clean - - name: Push and Commit - env: - CI_COMMIT_NAME: "Automated commit" - CI_COMMIT_EMAIL: "actions@users.noreply.github.com" - CI_COMMIT_MESSAGE: "Automated commit" - run: | - git config --global user.email "${{env.CI_COMMIT_EMAIL}}" - git config --global user.name "${{env.CI_COMMIT_NAME}}" - git diff --quiet && echo "No changes to commit" || ( - git add data/ && - git commit -m "${{env.CI_COMMIT_MESSAGE}}" && - git push origin main # Specify the branch - ) \ No newline at end of file + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "Automated commit" + branch: automated-update-branch + title: "Automated Data Update" + body: "Automated changes by [create-pull-request](https://github.com/datasets/un-locode/pulls) GitHub action" + author: "actions@github.com " + labels: "automated update" \ No newline at end of file From 70a5e973d8e9681cdc4064abde737bafeaa06f3c Mon Sep 17 00:00:00 2001 From: gradedSystem Date: Wed, 23 Oct 2024 18:08:08 +0700 Subject: [PATCH 3/3] [fix][s] Making sure only data folder updated --- .github/workflows/actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 6bbf5ad633..202fd8a456 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -55,6 +55,7 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: + add-paths: data/*.csv commit-message: "Automated commit" branch: automated-update-branch title: "Automated Data Update"