Skip to content

update python

update python #12

Workflow file for this run

name: Create X Post
on:
push:
branches:
- feature/x_automation_post
permissions:
contents: read
jobs:
tweet:
runs-on: ubuntu-latest
environment: X_Automation
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Get the latest file
run: |
cd Content/posts
# 最新のファイルを見つける
LATEST_FILE=$(ls *.md | awk -F '-' '{print $1}' | sort -n | tail -n 1)
echo "Latest file number: $LATEST_FILE"
# 最新のファイル名を取得し、.mdを取り除く
LATEST_FILENAME="${LATEST_FILE}-$(ls ${LATEST_FILE}-*.md | awk -F '-' '{print $2}')"
LATEST_FILENAME_NO_EXT="${LATEST_FILENAME%.md}" # .mdを削除
# 結果をGitHub Actionsの出力として設定
echo "Latest file name without extension: $LATEST_FILENAME_NO_EXT"
echo "latest_file_name=${LATEST_FILENAME}" >> $GITHUB_ENV
- name: Install dependencies
run: |
pip install tweepy
- name: Post article
env:
X_API_KEY: ${{ secrets.X_API_KEY }}
X_API_KEY_SECRET: ${{ secrets.X_API_KEY_SECRET }}
X_BEARER_TOKEN: ${{ secrets.X_BEARER_TOKEN }}
X_ACCESS_TOKEN: ${{ secrets.X_ACCESS_TOKEN }}
X_ACCESS_TOKEN_SECRET: ${{ secrets.X_ACCESS_TOKEN_SECRET }}
X_POST_MESSAGE: "この投稿は自動化をテストしている投稿です! ファイル名:${{ steps.get_latest_file.outputs.latest_filename }}"
run: python tweet.py