Twitter Back Up #2
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
name: Twitter Back Up | |
on: | |
workflow_dispatch: | |
inputs: | |
twitter_user_name: | |
description: 'twitter user name' | |
required: true | |
jobs: | |
twitter_backup: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ['3.8'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Check user permission | |
id: check | |
uses: scherermichael-oss/action-has-permission@master | |
with: | |
required-permission: write | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Use the output from the `check` step | |
- name: Run only if user has sufficient permissions | |
if: steps.check.outputs.has-permission | |
run: echo "Congratulations! Your permissions to access the repository are sufficient." | |
- name: Run only if user has NOT sufficient permissions | |
if: "! steps.check.outputs.has-permission" | |
run: | | |
echo "Sorry! Your permissions are insufficient. please check https://github.com/ad-m/github-push-action/issues/96" | |
exit 1 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# from pdm | |
- name: Set Variables | |
id: set_variables | |
run: | | |
echo "PY=$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_OUTPUT | |
echo "PIP_CACHE=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Cache PIP | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.set_variables.outputs.PIP_CACHE }} | |
key: Ubuntu-pip-${{ steps.set_variables.outputs.PY }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements-dev.txt | |
- name: Run twitter back up | |
run: | | |
python -m github_poster twitter --twitter_user_name "${{ github.event.inputs.twitter_user_name }}" --year 2007-$(date +"%Y") --me "${{ github.event.inputs.twitter_user_name }}" | tee OUT_FOLDER/"${{ github.event.inputs.twitter_user_name }}".txt | |
- name: Push new twitter back up | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add . | |
git commit -m 'update new poster' || echo "nothing to commit" | |
git push || echo "nothing to push" |