From 6828bbea8e9960ef741315f9c64332573e88c3bb Mon Sep 17 00:00:00 2001 From: gradedSystem Date: Fri, 22 Nov 2024 18:53:01 +0800 Subject: [PATCH] [ga-actions][m] Adding automated github actions --- .github/workflows/actions.yml | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 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 0000000..345bc3d --- /dev/null +++ b/.github/workflows/actions.yml @@ -0,0 +1,55 @@ +name: Update media-types data + +on: + schedule: + - cron: '0 0 * * 0' + + push: + branches: + - main + + pull_request: + branches: + - main + + 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 Script + run: | + python scripts/process.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 + ) \ No newline at end of file