relinkedin #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: relinkedin | |
on: | |
schedule: | |
- cron: '30 12 * * 2' | |
workflow_dispatch: | |
jobs: | |
post: | |
runs-on: windows-latest | |
env: | |
LI_CLIENT_ID: ${{ secrets.LI_CLIENT_ID}} | |
LI_CLIENT_SECRET: ${{ secrets.LI_CLIENT_SECRET}} | |
LI_REFRESH_TOKEN: ${{ secrets.LI_REFRESH_TOKEN}} | |
GITHUB_PAT: ${{ secrets.GH_PAT }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'renv' | |
- uses: r-lib/actions/setup-renv@v2 | |
with: | |
cache-version: 2 | |
- name: Fetch the latest successful run ID from linkedin workflow | |
id: fetch_run_id | |
run: | | |
RUN_ID=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/linkedin.yml/runs?status=success&branch=main&per_page=1" \ | |
| jq -r '.workflow_runs[0].id') | |
echo "Latest run ID: $RUN_ID" | |
echo "::set-output name=run_id::$RUN_ID" | |
- name: Load post ID. | |
uses: actions/download-artifact@v4 | |
with: | |
name: li_post_id | |
run-id: ${{ steps.fetch_run_id.outputs.run_id }} | |
path: li_post_id.rds | |
- name: Repost on LinkedIn. | |
run: Rscript dslc-relink.R |