Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix weblate labeling #574

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@babel/preset-env",
{
"targets": {
"node": "12"
"node": "14"
}
}
]
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,34 @@ on:
branches:
- master

env:
CI: true
TZ: 'Europe/Paris'
NODE_ENV: 'test'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]
node-version: [14.x]

steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: use node ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: install
run: yarn install
env:
CI: true
TZ: 'Europe/Paris'
NODE_ENV: 'test'

- name: lint
run: yarn lint
env:
CI: true
TZ: 'Europe/Paris'
NODE_ENV: 'test'

- name: test
run: yarn test
env:
CI: true
TZ: 'Europe/Paris'
NODE_ENV: 'test'
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
14
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Available lambdas:

## Prerequisites

- Node.js 12
- Serverless CLI v1.54.0 or later (`npm install -g serverless`)
- Node.js 14
- Serverless CLI v3.16.0 or later (`npm install -g serverless@3`)
- An AWS account
- Defined [provider credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/)

Expand Down
15 changes: 9 additions & 6 deletions functions/weblate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ export async function handler(event, context, callback) {
})
}

await githubClient.rest.issues.setLabels({
owner: body.repository.owner.login,
repo: body.repository.name,
issue_number: body.pull_request.number,
labels: [{ name: 'Translations' }],
})
const owner = body.repository.owner.login
const repo = body.repository.name

await githubClient.request(
`POST /repos/${owner}/${repo}/issues/${body.pull_request.number}/labels`,
{
labels: ['Translations'],
}
)

console.log('Labelled!')

Expand Down
8 changes: 5 additions & 3 deletions serverless.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
frameworkVersion: ">=1.54.0 <2.0.0"
frameworkVersion: ">=3.16.0"

service: wallabag-serverless-bot

Expand All @@ -15,13 +15,15 @@ custom:

provider:
name: aws
runtime: nodejs12.x
runtime: nodejs14.x
profile: default
region: ${opt:region, 'eu-west-1'}
versionFunctions: false
deploymentMethod: direct
environment:
NAMESPACE: Site config
# SecureString from SSM Parameters
GITHUB_TOKEN: ${ssm:GITHUB_TOKEN~true}
GITHUB_TOKEN: ${ssm:GITHUB_TOKEN}

functions:
extension:
Expand Down
4 changes: 2 additions & 2 deletions tests/weblate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ describe('Apply label', () => {

test('PR is ok', async () => {
nock('https://api.github.com')
.put('/repos/foo/bar/issues/42/labels', (body) => {
expect(body.labels[0].name).toBe('Translations')
.post('/repos/foo/bar/issues/42/labels', (body) => {
expect(body.labels[0]).toBe('Translations')

return true
})
Expand Down
Loading