[Github Actions] github 출시 공개에 맞춰 트위터로 알림
개요
github의 모든 리포지토리의 release가 공개된 타이밍에 트윗을 하는 Github Actions를 만들어 갑니다.
GitHub Marketplace
htps : // 기주 b. 코 m / 마 r tp ぁ 세 / 아 c 치 온 s / t t t t rig r pu b sh sh ぇ
리포지토리
htps : // 기주 b. 코 m / 무기 111 /
만드는 방법
↓↓↓ 만드는 방법의 참고로 한 페이지입니다↓↓↓
LGTM하면 현장 고양이가 "요시!" 해주는 GitHub Actions를 만들었다 + Tips
이번에는 여기 자바 스크립트 템플릿을 사용하여 만들었습니다.
github에 로그인하여 리포지토리 페이지로 이동하면 녹색 Use this template
라는 버튼이 표시됩니다.

언제나 거리의 익숙한 페이지로 이동하므로, 여기에서 자신의 리포지토리를 작성해 갑니다.

템플릿 이외에 사용하는 것으로서 이번에는 트위터 패키지를 설치합니다.
npmnpm i twitter --save
yarnyarn add twitter
제작은 간단하고 트위터 API를 사용하여 트윗을 POST하면됩니다.client
의 선언이나 트윗 본문의 지정으로 사용되고 있다
core.getInput(' xxx ')
이 기술로 후술하는 .github/workflow
바로 아래의 yaml 파일로부터 값을 취득해 옵니다.
아래는 코드의 전체 텍스트입니다.
index.jsconst core = require('@actions/core');
const Twitter = require('twitter');
// most @actions toolkit packages have async methods
async function run() {
try {
const client = new Twitter({
consumer_key: core.getInput('consumer_key'),
consumer_secret: core.getInput('consumer_secret'),
access_token_key: core.getInput('access_token_key'),
access_token_secret: core.getInput('access_token_secret')
});
client.post('statuses/update', {status: core.getInput('tweet_body')}, (error) => {
if (!error) {
console.log('Succeeded!');
} else {
console.log('Couldnt tweet.');
}
});
}
catch (error) {
core.setFailed(error.message);
}
}
run()
yaml 파일의 내용
이 부분에서 release
의 published
를 트리거로 하는 것을 정의하고 있습니다.
on:
release:
types: [published]
그리고는 실행 환경이나 사용하는 Actions, 입력하는 값을 설정합니다.
build:
runs-on: ubuntu-latest
steps:
- uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.CONSUMER_KEY }}
consumer_secret: ${{ secrets.CONSUMER_SECRET }}
access_token_key: ${{ secrets.ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }}
tweet_body: "更新しました!"
사용법
다음 yaml 파일은 .github/workflow
바로 아래에 있습니다.
tweet-trigger-release.ymlname: "tweet-trigger-release"
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.CONSUMER_KEY }}
consumer_secret: ${{ secrets.CONSUMER_SECRET }}
access_token_key: ${{ secrets.ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }}
tweet_body: "更新しました!"
여기 secrets.XXX
를 설정하기 위해 Settings의 Secrets 탭에서 Twitter의 Developer 페이지에서 얻은 token과 key를 등록합니다.

Twitter API 등록(계정 신청 방법)으로부터 승인될 때까지의 순서 정리※2019년 8월 시점의 정보
htps : // m / kn gsym 2018 / ms / 2524d21455 오 c111c
그리고는 "更新しました!"
로 되어 있다 tweet_body
를 고쳐 쓰는 것으로 트윗의 본문을 설정해 완료입니다.
끝
Reference
이 문제에 관하여([Github Actions] github 출시 공개에 맞춰 트위터로 알림), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/mugi111/items/dd033745f61c36bc3c1a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
↓↓↓ 만드는 방법의 참고로 한 페이지입니다↓↓↓
LGTM하면 현장 고양이가 "요시!" 해주는 GitHub Actions를 만들었다 + Tips
이번에는 여기 자바 스크립트 템플릿을 사용하여 만들었습니다.
github에 로그인하여 리포지토리 페이지로 이동하면 녹색
Use this template
라는 버튼이 표시됩니다.
언제나 거리의 익숙한 페이지로 이동하므로, 여기에서 자신의 리포지토리를 작성해 갑니다.

템플릿 이외에 사용하는 것으로서 이번에는 트위터 패키지를 설치합니다.
npm
npm i twitter --save
yarn
yarn add twitter
제작은 간단하고 트위터 API를 사용하여 트윗을 POST하면됩니다.
client
의 선언이나 트윗 본문의 지정으로 사용되고 있다core.getInput(' xxx ')
이 기술로 후술하는
.github/workflow
바로 아래의 yaml 파일로부터 값을 취득해 옵니다.아래는 코드의 전체 텍스트입니다.
index.js
const core = require('@actions/core');
const Twitter = require('twitter');
// most @actions toolkit packages have async methods
async function run() {
try {
const client = new Twitter({
consumer_key: core.getInput('consumer_key'),
consumer_secret: core.getInput('consumer_secret'),
access_token_key: core.getInput('access_token_key'),
access_token_secret: core.getInput('access_token_secret')
});
client.post('statuses/update', {status: core.getInput('tweet_body')}, (error) => {
if (!error) {
console.log('Succeeded!');
} else {
console.log('Couldnt tweet.');
}
});
}
catch (error) {
core.setFailed(error.message);
}
}
run()
yaml 파일의 내용
이 부분에서 release
의 published
를 트리거로 하는 것을 정의하고 있습니다.
on:
release:
types: [published]
그리고는 실행 환경이나 사용하는 Actions, 입력하는 값을 설정합니다.
build:
runs-on: ubuntu-latest
steps:
- uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.CONSUMER_KEY }}
consumer_secret: ${{ secrets.CONSUMER_SECRET }}
access_token_key: ${{ secrets.ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }}
tweet_body: "更新しました!"
사용법
다음 yaml 파일은 .github/workflow
바로 아래에 있습니다.
tweet-trigger-release.ymlname: "tweet-trigger-release"
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.CONSUMER_KEY }}
consumer_secret: ${{ secrets.CONSUMER_SECRET }}
access_token_key: ${{ secrets.ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }}
tweet_body: "更新しました!"
여기 secrets.XXX
를 설정하기 위해 Settings의 Secrets 탭에서 Twitter의 Developer 페이지에서 얻은 token과 key를 등록합니다.

Twitter API 등록(계정 신청 방법)으로부터 승인될 때까지의 순서 정리※2019년 8월 시점의 정보
htps : // m / kn gsym 2018 / ms / 2524d21455 오 c111c
그리고는 "更新しました!"
로 되어 있다 tweet_body
를 고쳐 쓰는 것으로 트윗의 본문을 설정해 완료입니다.
끝
Reference
이 문제에 관하여([Github Actions] github 출시 공개에 맞춰 트위터로 알림), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/mugi111/items/dd033745f61c36bc3c1a
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
on:
release:
types: [published]
build:
runs-on: ubuntu-latest
steps:
- uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.CONSUMER_KEY }}
consumer_secret: ${{ secrets.CONSUMER_SECRET }}
access_token_key: ${{ secrets.ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }}
tweet_body: "更新しました!"
다음 yaml 파일은
.github/workflow
바로 아래에 있습니다.tweet-trigger-release.yml
name: "tweet-trigger-release"
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: mugi111/[email protected]
with:
consumer_key: ${{ secrets.CONSUMER_KEY }}
consumer_secret: ${{ secrets.CONSUMER_SECRET }}
access_token_key: ${{ secrets.ACCESS_TOKEN_KEY }}
access_token_secret: ${{ secrets.ACCESS_TOKEN_SECRET }}
tweet_body: "更新しました!"
여기
secrets.XXX
를 설정하기 위해 Settings의 Secrets 탭에서 Twitter의 Developer 페이지에서 얻은 token과 key를 등록합니다.
Twitter API 등록(계정 신청 방법)으로부터 승인될 때까지의 순서 정리※2019년 8월 시점의 정보
htps : // m / kn gsym 2018 / ms / 2524d21455 오 c111c
그리고는
"更新しました!"
로 되어 있다 tweet_body
를 고쳐 쓰는 것으로 트윗의 본문을 설정해 완료입니다.끝
Reference
이 문제에 관하여([Github Actions] github 출시 공개에 맞춰 트위터로 알림), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/mugi111/items/dd033745f61c36bc3c1a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)