From 488dd5137030d939ce037742a28c6bb73248c3b7 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 13 Oct 2022 11:59:33 -0700 Subject: [PATCH 1/6] Copy to local --- .github/actions/send-tweet/README.md | 49 +++++++++++++++++++++++++ .github/actions/send-tweet/action.yml | 35 ++++++++++++++++++ .github/actions/send-tweet/index.js | 37 +++++++++++++++++++ .github/actions/send-tweet/package.json | 23 ++++++++++++ .github/workflows/release-tweet.yml | 2 +- 5 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 .github/actions/send-tweet/README.md create mode 100644 .github/actions/send-tweet/action.yml create mode 100644 .github/actions/send-tweet/index.js create mode 100644 .github/actions/send-tweet/package.json diff --git a/.github/actions/send-tweet/README.md b/.github/actions/send-tweet/README.md new file mode 100644 index 00000000000..eda484f608a --- /dev/null +++ b/.github/actions/send-tweet/README.md @@ -0,0 +1,49 @@ +# Send Tweet GitHub Action + +This is a minimalistic GitHub Action for posting Firebase release announcements +to Twitter. Simply specify the Twitter API keys along with the Tweet status to +be posted. + +## Inputs + +### `status` + +**Required** Text of the Tweet to send. + +### `consumer-key` + +**Required** Consumer API key from Twitter. + +### `consumer-secret` + +**Required** Consumer API secret key from Twitter. + +### `access-token` + +**Required** Twitter application access token. + +### `access-token-secret` + +**Required** Twitter application access token secret. + +## Example usage + +``` +- name: Send Tweet + uses: firebase/firebase-admin-node/.github/actions/send-tweet + with: + status: > + v1.2.3 of @Firebase Admin Node.js SDK is available. + Release notes at https://firebase.google.com. + consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }} + consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }} + access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} + access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} +``` + +## Implementation + +This Action uses the `twitter` NPM package to send Tweets. + +When making a code change remember to run `npm run pack` to rebuild the +`dist/index.js` file which is the executable of this Action. diff --git a/.github/actions/send-tweet/action.yml b/.github/actions/send-tweet/action.yml new file mode 100644 index 00000000000..bb45748d4b7 --- /dev/null +++ b/.github/actions/send-tweet/action.yml @@ -0,0 +1,35 @@ +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 'Send Tweet Action' +description: 'Send Tweets from GitHub Actions workflows.' +inputs: + status: + description: Status (Tweet) to be posted + required: true + consumer-key: + description: Consumer API key. + required: true + consumer-secret: + description: Consumer API secret key. + required: true + access-token: + description: Application access token. + required: true + access-token-secret: + description: Application access token secret. + required: true +runs: + using: 'node12' + main: 'dist/index.js' diff --git a/.github/actions/send-tweet/index.js b/.github/actions/send-tweet/index.js new file mode 100644 index 00000000000..aa6140ba8b8 --- /dev/null +++ b/.github/actions/send-tweet/index.js @@ -0,0 +1,37 @@ +/*! + * Copyright 2020 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const core = require('@actions/core'); +const Twitter = require('twitter'); + +function sendTweet() { + const twitter = new Twitter({ + consumer_key: core.getInput('consumer-key'), + consumer_secret: core.getInput('consumer-secret'), + access_token_key: core.getInput('access-token'), + access_token_secret: core.getInput('access-token-secret') + }); + + return twitter.post('/statuses/update', {status: core.getInput('status')}) + .then(() => { + return; + }) + .catch((err) => { + core.setFailed(err.message); + }); +} + +sendTweet(); diff --git a/.github/actions/send-tweet/package.json b/.github/actions/send-tweet/package.json new file mode 100644 index 00000000000..520b1281523 --- /dev/null +++ b/.github/actions/send-tweet/package.json @@ -0,0 +1,23 @@ +{ + "name": "send-tweet", + "version": "1.0.0", + "description": "Send Tweets from GitHub Actions workflows.", + "main": "index.js", + "scripts": { + "pack": "ncc build" + }, + "keywords": [ + "Firebase", + "Release", + "Automation" + ], + "author": "Firebase (https://firebase.google.com/)", + "license": "Apache-2.0", + "dependencies": { + "@actions/core": "^1.9.1", + "twitter": "^1.7.1" + }, + "devDependencies": { + "@zeit/ncc": "^0.21.1" + } +} diff --git a/.github/workflows/release-tweet.yml b/.github/workflows/release-tweet.yml index 708132d93d8..56d01e70d35 100644 --- a/.github/workflows/release-tweet.yml +++ b/.github/workflows/release-tweet.yml @@ -24,7 +24,7 @@ jobs: VERSION: ${{ github.event.inputs.version }} FORCE_PUBLISH: ${{ github.event.inputs.force }} - name: Post to Twitter - uses: firebase/firebase-admin-node/.github/actions/send-tweet + uses: ./.github/actions/send-tweet with: status: > v${{github.event.inputs.version}} of @Firebase JavaScript client for Web / Node.js is available. From b73ba07ecebc1b9ee57cf20d3b935382831f4d50 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 13 Oct 2022 13:35:02 -0700 Subject: [PATCH 2/6] Try different formatting of action --- .github/actions/send-tweet/README.md | 49 ------------------------- .github/actions/send-tweet/action.yml | 35 ------------------ .github/actions/send-tweet/index.js | 37 ------------------- .github/actions/send-tweet/package.json | 23 ------------ .github/workflows/release-tweet.yml | 2 +- 5 files changed, 1 insertion(+), 145 deletions(-) delete mode 100644 .github/actions/send-tweet/README.md delete mode 100644 .github/actions/send-tweet/action.yml delete mode 100644 .github/actions/send-tweet/index.js delete mode 100644 .github/actions/send-tweet/package.json diff --git a/.github/actions/send-tweet/README.md b/.github/actions/send-tweet/README.md deleted file mode 100644 index eda484f608a..00000000000 --- a/.github/actions/send-tweet/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Send Tweet GitHub Action - -This is a minimalistic GitHub Action for posting Firebase release announcements -to Twitter. Simply specify the Twitter API keys along with the Tweet status to -be posted. - -## Inputs - -### `status` - -**Required** Text of the Tweet to send. - -### `consumer-key` - -**Required** Consumer API key from Twitter. - -### `consumer-secret` - -**Required** Consumer API secret key from Twitter. - -### `access-token` - -**Required** Twitter application access token. - -### `access-token-secret` - -**Required** Twitter application access token secret. - -## Example usage - -``` -- name: Send Tweet - uses: firebase/firebase-admin-node/.github/actions/send-tweet - with: - status: > - v1.2.3 of @Firebase Admin Node.js SDK is available. - Release notes at https://firebase.google.com. - consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }} - consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }} - access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }} - access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} -``` - -## Implementation - -This Action uses the `twitter` NPM package to send Tweets. - -When making a code change remember to run `npm run pack` to rebuild the -`dist/index.js` file which is the executable of this Action. diff --git a/.github/actions/send-tweet/action.yml b/.github/actions/send-tweet/action.yml deleted file mode 100644 index bb45748d4b7..00000000000 --- a/.github/actions/send-tweet/action.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2020 Google Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 'Send Tweet Action' -description: 'Send Tweets from GitHub Actions workflows.' -inputs: - status: - description: Status (Tweet) to be posted - required: true - consumer-key: - description: Consumer API key. - required: true - consumer-secret: - description: Consumer API secret key. - required: true - access-token: - description: Application access token. - required: true - access-token-secret: - description: Application access token secret. - required: true -runs: - using: 'node12' - main: 'dist/index.js' diff --git a/.github/actions/send-tweet/index.js b/.github/actions/send-tweet/index.js deleted file mode 100644 index aa6140ba8b8..00000000000 --- a/.github/actions/send-tweet/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * Copyright 2020 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const core = require('@actions/core'); -const Twitter = require('twitter'); - -function sendTweet() { - const twitter = new Twitter({ - consumer_key: core.getInput('consumer-key'), - consumer_secret: core.getInput('consumer-secret'), - access_token_key: core.getInput('access-token'), - access_token_secret: core.getInput('access-token-secret') - }); - - return twitter.post('/statuses/update', {status: core.getInput('status')}) - .then(() => { - return; - }) - .catch((err) => { - core.setFailed(err.message); - }); -} - -sendTweet(); diff --git a/.github/actions/send-tweet/package.json b/.github/actions/send-tweet/package.json deleted file mode 100644 index 520b1281523..00000000000 --- a/.github/actions/send-tweet/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "send-tweet", - "version": "1.0.0", - "description": "Send Tweets from GitHub Actions workflows.", - "main": "index.js", - "scripts": { - "pack": "ncc build" - }, - "keywords": [ - "Firebase", - "Release", - "Automation" - ], - "author": "Firebase (https://firebase.google.com/)", - "license": "Apache-2.0", - "dependencies": { - "@actions/core": "^1.9.1", - "twitter": "^1.7.1" - }, - "devDependencies": { - "@zeit/ncc": "^0.21.1" - } -} diff --git a/.github/workflows/release-tweet.yml b/.github/workflows/release-tweet.yml index 56d01e70d35..9a9def7ef39 100644 --- a/.github/workflows/release-tweet.yml +++ b/.github/workflows/release-tweet.yml @@ -24,7 +24,7 @@ jobs: VERSION: ${{ github.event.inputs.version }} FORCE_PUBLISH: ${{ github.event.inputs.force }} - name: Post to Twitter - uses: ./.github/actions/send-tweet + uses: firebase/firebase-admin-node/.github/actions/send-tweet@master with: status: > v${{github.event.inputs.version}} of @Firebase JavaScript client for Web / Node.js is available. From 2f501564b9a725fbc211652d88ea32063ad1c7ee Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 13 Oct 2022 14:05:08 -0700 Subject: [PATCH 3/6] add node setup step --- .github/workflows/release-tweet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release-tweet.yml b/.github/workflows/release-tweet.yml index 9a9def7ef39..50dd9f01bde 100644 --- a/.github/workflows/release-tweet.yml +++ b/.github/workflows/release-tweet.yml @@ -18,6 +18,10 @@ jobs: name: Send Release Tweet runs-on: ubuntu-latest steps: + - name: Setup Node.js 14.x + uses: actions/setup-node@master + with: + node-version: 14.x - name: Poll release notes page on devsite run: node scripts/ci/poll_release_notes.js env: From 21dacafd3137dba63caed4ecbcf999b93a6b993e Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 13 Oct 2022 14:10:25 -0700 Subject: [PATCH 4/6] checkout repo! --- .github/workflows/release-tweet.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-tweet.yml b/.github/workflows/release-tweet.yml index 50dd9f01bde..096171880fb 100644 --- a/.github/workflows/release-tweet.yml +++ b/.github/workflows/release-tweet.yml @@ -18,6 +18,8 @@ jobs: name: Send Release Tweet runs-on: ubuntu-latest steps: + - name: Checkout Repo + uses: actions/checkout@master - name: Setup Node.js 14.x uses: actions/setup-node@master with: From d0e8ef80a8d151f976c99fcf37ac5d99dd99424e Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 13 Oct 2022 14:22:56 -0700 Subject: [PATCH 5/6] Fix script --- scripts/ci/poll_release_notes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/poll_release_notes.js b/scripts/ci/poll_release_notes.js index ed972ac0729..de8dfc24549 100644 --- a/scripts/ci/poll_release_notes.js +++ b/scripts/ci/poll_release_notes.js @@ -52,7 +52,7 @@ async function pollReleaseNotes() { for (let i = 0; i < MAX_ATTEMPTS; i++) { siteContent = await getData(); const matches = siteContent.match(//g); - if (matches[0] === version) { + if (matches[0] === ``) { return; } if (matches.includes(``) && !process.env.FORCE) { From eb58cc38109d516904c910af013e7cdb584ac067 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Thu, 13 Oct 2022 14:26:21 -0700 Subject: [PATCH 6/6] Add a success message --- scripts/ci/poll_release_notes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci/poll_release_notes.js b/scripts/ci/poll_release_notes.js index de8dfc24549..9a5ea4f2105 100644 --- a/scripts/ci/poll_release_notes.js +++ b/scripts/ci/poll_release_notes.js @@ -53,6 +53,7 @@ async function pollReleaseNotes() { siteContent = await getData(); const matches = siteContent.match(//g); if (matches[0] === ``) { + console.log(`Found ${version} in release notes.`); return; } if (matches.includes(``) && !process.env.FORCE) {