Skip to content

Commit

Permalink
feat: migrate to GitHub Actions v2
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 1, 2019
1 parent c81108d commit 7c0fb20
Show file tree
Hide file tree
Showing 15 changed files with 3,580 additions and 4,294 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
branches:
- master
name: release
jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@v1
with:
node-version: "12.x"
- run: npm ci
- run: npm run build
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on: [push, pull_request]
name: Test
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "12.x"
- run: npm ci
- run: npm run build
- run: npm test
29 changes: 29 additions & 0 deletions .github/workflows/twitter-together.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on: [push, pull_request]
name: Twitter, together!
jobs:
preview:
name: Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run: npm ci
- run: npm run build
- name: Preview
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tweet:
name: Tweet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- run: npm ci
- run: npm run build
- name: Tweet
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_API_SECRET_KEY: ${{ secrets.TWITTER_API_SECRET_KEY }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
.nyc_output
coverage
coverage/
dist/
node_modules/
22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

56 changes: 31 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1 align="center">Twitter, together!</h1>

<p align="center">
<a href="https://action-badges.now.sh" rel="nofollow"><img alt="Build Status" src="https://action-badges.now.sh/gr2m/twitter-together?workflow=Test"></a>
<a href="https://action-badges.now.sh" rel="nofollow"><img alt="Build Status" src="https://github.com/gr2m/twitter-together/workflows/Test/badge.svg"></a>
<a href="https://github.com/gr2m/twitter-together/blob/80c8aab34382347120e22501c2e44f30a7a62174/package.json#L8" rel="nofollow"><img alt="Coverage" src="https://img.shields.io/badge/coverage-100%25-green.svg"></a>
<a href="https://greenkeeper.io/" rel="nofollow"><img src="https://badges.greenkeeper.io/gr2m/twitter-together.svg?token=fec4ee116d4210bb3f03e13bed6266d5fc8e8764def4f269753e522abfba3a19&ts=1550824957051"></a>
</p>
Expand Down Expand Up @@ -36,31 +36,37 @@ You can submit a tweet to this repository to see the magic happen. Please follow
## Setup

1. [Create a twitter](docs/01-create-twitter-app.md) app with your shared twitter account and store the credentials as `TWITTER_API_KEY`, `TWITTER_API_SECRET_KEY`, `TWITTER_ACCESS_TOKEN` and `TWITTER_ACCESS_TOKEN_SECRET` in your repository’s secrets settings.
2. [Create a `.github/main.workflow` file](docs/02-create-main.workflow.md) or amend your existing one with the content below

```workflow
workflow "Tweet on push to default branch" {
on = "push"
resolves = ["Tweet"]
}
action "Tweet" {
uses = "gr2m/twitter-together@master"
secrets = ["GITHUB_TOKEN", "TWITTER_API_KEY", "TWITTER_API_SECRET_KEY", "TWITTER_ACCESS_TOKEN", "TWITTER_ACCESS_TOKEN_SECRET"]
}
# "push" event won’t work on forks, hence the 2nd workflow with "pull_request"
workflow "Preview and validate tweets on pull requests" {
on = "pull_request"
resolves = ["Preview"]
}
action "Preview" {
uses = "gr2m/twitter-together@master"
secrets = ["GITHUB_TOKEN"]
}
2. [Create a `.github/workflows/twitter-together.yml` file](docs/02-create-twitter-together-workflow.md) or amend your existing one with the content below

```yml
on: [push, pull_request]
name: Twitter, together!
jobs:
preview:
name: Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Preview
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tweet:
name: Tweet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Tweet
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_API_SECRET_KEY: ${{ secrets.TWITTER_API_SECRET_KEY }}
```
3. After creating or updating `.github/main.workflow` in your repository’s default branch, a pull request will be created with further instructions.
3. After creating or updating `.github/workflows/twitter-together.yml` in your repository’s default branch, a pull request will be created with further instructions.

Happy collaborative tweeting!

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: Twitter, together!
description: "Collaborate on tweets just like you collaborate on code, using pull requests"
runs:
using: "node12"
main: "dist/index.js"
52 changes: 52 additions & 0 deletions docs/02-create-twitter-together-workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[back to README.md](../README.md/#setup)

# Create a `.github/main.workflow` file

In your repository, open the Actions tab.

![](workflow-01-actions-tab.png)

Press the <kbd>Setup a new workflow yourself</kbd> button to open the file editor.

![](workflow-02-editor.png)

In the filename input above the code area, replace `main.yml` with `twitter-together.yml`. Then replace the code below with the following

```yml
on: [push, pull_request]
name: Twitter, together!
jobs:
preview:
name: Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Preview
uses: gr2m/twitter-together@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tweet:
name: Tweet
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Tweet
uses: gr2m/twitter-together@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_API_SECRET_KEY: ${{ secrets.TWITTER_API_SECRET_KEY }}

```

![](workflow-04-commit.png)

To create the file, press the <kbd>Start commit</kbd> button. You can optionally set a custom commit message, then press <kbd>Commit new file</kbd>.

---

Nearly done! Shortly after creating or updating `.github/main.workflow` in your repository’s default branch, a pull request will be created with further instructions.

[back to README.md](../README.md/#setup)
Binary file modified docs/workflow-01-actions-tab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/workflow-02-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/workflow-02-visual-editor.png
Binary file not shown.
Binary file removed docs/workflow-03-code-editor.png
Binary file not shown.
Binary file added docs/workflow-03-commit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7c0fb20

Please # to comment.