-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (84 loc) · 3.4 KB
/
post-sns.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Post SNS
on:
pull_request:
types: [closed]
branches:
- main
permissions:
pull-requests: read
contents: read
jobs:
post-sns:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'sns')
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
# https://github.com/actions/setup-node
- uses: actions/setup-node@v4
with:
node-version: "20" # Updated to latest LTS version
# https://github.com/plhery/node-twitter-api-v2
# https://github.com/linkedin-developers/linkedin-api-js-client#linkedin-api-javascript-client
- name: Install dependencies
run: |
npm install twitter-api-v2
npm install linkedin-api-client
npm install playwright
npx playwright install chromium
- name: Wait for deployment
run: sleep 600 # Wait for 10 minutes (600 seconds)
- name: Check blog post
id: blog-check
uses: actions/github-script@v7
with:
script: |
const { getBlogInfo } = require('.github/scripts/utils.js');
const { isBlog, postUrl } = await getBlogInfo({ github, context });
core.setOutput('isBlog', isBlog);
core.setOutput('postUrl', postUrl);
# https://github.com/actions/github-script
- name: Post to X
uses: actions/github-script@v7
with:
script: |
const postTwitter = require('.github/scripts/post-twitter.js');
const isBlog = ${{ steps.blog-check.outputs.isBlog }};
const postUrl = '${{ steps.blog-check.outputs.postUrl }}';
await postTwitter({ context, isBlog, postUrl });
env:
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_API_SECRET: ${{ secrets.TWITTER_API_SECRET }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
- name: Post to LinkedIn
uses: actions/github-script@v7
with:
script: |
const postLinkedIn = require('.github/scripts/post-linkedin.js');
const isBlog = ${{ steps.blog-check.outputs.isBlog }};
const postUrl = '${{ steps.blog-check.outputs.postUrl }}';
await postLinkedIn({ context, isBlog, postUrl });
env:
LINKEDIN_ACCESS_TOKEN: ${{ secrets.LINKEDIN_ACCESS_TOKEN }}
- name: Post to Hacker News
uses: actions/github-script@v7
with:
script: |
const postHackerNews = require('.github/scripts/post-hackernews.js');
const isBlog = ${{ steps.blog-check.outputs.isBlog }};
const postUrl = '${{ steps.blog-check.outputs.postUrl }}';
await postHackerNews({ context, isBlog, postUrl });
env:
HN_USERNAME: ${{ secrets.HN_USERNAME }}
HN_PASSWORD: ${{ secrets.HN_PASSWORD }}
- name: Post to Dev.to
uses: actions/github-script@v7
with:
script: |
const postDevTo = require('.github/scripts/post-devto.js');
const isBlog = ${{ steps.blog-check.outputs.isBlog }};
const postUrl = '${{ steps.blog-check.outputs.postUrl }}';
await postDevTo({ isBlog, postUrl });
env:
DEVTO_API_KEY: ${{ secrets.DEVTO_API_KEY_WES }}