From 7b7893ecd631149b5b1acb0497551cb5b6057b4b Mon Sep 17 00:00:00 2001 From: Bee Webb Date: Wed, 6 Nov 2024 13:50:42 +0000 Subject: [PATCH 1/2] git.sh: Switch back to using git.sh for doing deploy From https://github.com/IATI/IATI-Dashboard/blob/923f65caac8b3032e516c93d36e4f9b6f0ff0653/git.sh --- .github/workflows/build.yml | 75 ------------------------------------- git.sh | 34 +++++++++++++++++ 2 files changed, 34 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100755 git.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 76d5e869da..0000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Build -on: - push: - branches: - - dev - workflow_dispatch: # for triggering builds manually - repository_dispatch: - types: - - build -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout this repo - uses: actions/checkout@v3 - with: - persist-credentials: false - - name: Set up Python 3.7 - uses: actions/setup-python@v4 - with: - python-version: 3.7 - - uses: actions/cache@v3 - name: Cache dependencies - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - name: Fetch data - run: ./fetch_data.sh - - name: Fetch stats - run: | - mkdir out - ./get_stats.sh - - name: Make plots - run: python plots.py - - name: Build CSV output - run: python make_csv.py - - name: Build HTML output - run: python make_html.py - - name: Delete files - run: rm -rf data stats-calculated - - name: Deploy (production) 🚀 - if: github.ref == 'refs/heads/main' - uses: JamesIves/github-pages-deploy-action@v4 - with: - git-config-name: Code for IATI bot - git-config-email: 57559326+codeforIATIbot@users.noreply.github.com - token: ${{ secrets.TOKEN }} - repository-name: codeforIATI/analytics-public - branch: gh-pages - folder: out - clean: true - silent: true - single-commit: true - - name: Set CNAME (dev) - if: github.ref == 'refs/heads/dev' - run: echo "analytics-dev.codeforiati.org" > out/CNAME - - name: Deploy (dev) 🚀 - if: github.ref == 'refs/heads/dev' - uses: JamesIves/github-pages-deploy-action@v4 - with: - git-config-name: Code for IATI bot - git-config-email: 57559326+codeforIATIbot@users.noreply.github.com - token: ${{ secrets.TOKEN }} - repository-name: codeforIATI/analytics-dev - branch: gh-pages - folder: out - clean: true - silent: true - single-commit: true diff --git a/git.sh b/git.sh new file mode 100755 index 0000000000..c7b6c780a5 --- /dev/null +++ b/git.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Starting Dashboard generation" + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Removing 'out' directory and creating a new one" +rm -rf out +mkdir out + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Fetching data" +./fetch_data.sh &> fetch_data.log || exit 1 + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running plots.py" +python plots.py || exit 1 + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running make_csv.py" +python make_csv.py || exit 1 + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running speakers kit.py" +python speakers_kit.py || exit 1 + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running make_html.py" +python make_html.py $1 $2|| exit 1 + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Copying static elements" +cp static/img/favicon.png out/ +cp static/img/tablesorter-icons.gif out/ + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Make a backup of the old web directory and make new content live" +rsync -a --delete web web.bk +mv web web.1 +mv out web +rm -rf web.1 + +echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Dashboard generation complete" From 4511550737f075fe5d860fc16b59c08e9a441e20 Mon Sep 17 00:00:00 2001 From: Bee Webb Date: Wed, 6 Nov 2024 13:50:05 +0000 Subject: [PATCH 2/2] git.sh: Update for dynamic django deploy --- git.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/git.sh b/git.sh index c7b6c780a5..c6c0e70178 100755 --- a/git.sh +++ b/git.sh @@ -9,8 +9,10 @@ mkdir out echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Fetching data" ./fetch_data.sh &> fetch_data.log || exit 1 +cd dashboard + echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running plots.py" -python plots.py || exit 1 +python make_plots.py || exit 1 echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running make_csv.py" python make_csv.py || exit 1 @@ -18,12 +20,7 @@ python make_csv.py || exit 1 echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running speakers kit.py" python speakers_kit.py || exit 1 -echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running make_html.py" -python make_html.py $1 $2|| exit 1 - -echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Copying static elements" -cp static/img/favicon.png out/ -cp static/img/tablesorter-icons.gif out/ +cd .. echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Make a backup of the old web directory and make new content live" rsync -a --delete web web.bk