79 Commits

Author SHA1 Message Date
dependabot[bot]
8298c84342 Bump node-fetch from 2.6.1 to 2.6.7 in /.github/actions/test-action
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-18 14:47:52 +00:00
Stephan
c0b18d2f43 exp 2022-03-18 15:47:17 +01:00
Stephan
af2ea06031 fix 2022-01-10 20:05:10 +01:00
Stephan
eb36d5f680 fix 2022-01-10 20:00:34 +01:00
Stephan
e0f2b0031a fix 2022-01-10 19:53:04 +01:00
Stephan
59c7f9c4ce fix 2022-01-10 19:25:02 +01:00
Stephan
c26fc558a8 fix 2022-01-10 19:21:00 +01:00
Stephan
0b3a88b35a fix 2022-01-10 19:14:40 +01:00
Stephan
1da26533a1 fix 2022-01-10 18:51:48 +01:00
Stephan
702e7112e2 fix 2022-01-10 18:49:04 +01:00
Stephan
6a00c973fb fix 2022-01-10 18:39:14 +01:00
Stephan
a7ff547627 fix 2022-01-10 16:02:56 +01:00
Stephan
46233a24ae fix 2022-01-10 15:57:24 +01:00
Stephan
0741c67ed3 fix 2022-01-10 15:55:57 +01:00
Stephan
2d88efd6e2 fix 2022-01-10 15:23:50 +01:00
Stephan
2926b8c82d fix 2022-01-10 15:16:02 +01:00
Stephan
48eb74f956 fix 2022-01-10 15:05:08 +01:00
Stephan
021137402f fix 2022-01-10 15:02:03 +01:00
Stephan
4227e0fa09 fix 2022-01-10 14:59:04 +01:00
Stephan
f1101d51bc fix 2022-01-10 14:41:24 +01:00
Stephan
1e8aa06e8f fix 2022-01-10 14:38:36 +01:00
Stephan
7df140fdbb fix 2022-01-10 14:37:03 +01:00
Stephan
d3f5d490e6 fix 2022-01-10 14:34:34 +01:00
Stephan
2b75661fd2 fix 2022-01-10 13:25:02 +01:00
Stephan
bd262a8978 fix 2022-01-10 13:23:53 +01:00
Stephan
14e56223cd fix 2022-01-10 13:22:35 +01:00
Stephan
a8da58dd52 make it minimal 2022-01-10 12:10:30 +01:00
Stephan
522b08f4fb fix 2022-01-10 11:28:16 +01:00
Stephan
1124d1661a test assign-milestone 2022-01-10 11:25:09 +01:00
Stephan
7c3bb81709 cleanup 2022-01-10 08:16:46 +01:00
Stephan
3d32dbd623 fix 2021-12-20 19:22:26 +01:00
Stephan
e902f2afac fix 2021-12-20 19:16:22 +01:00
Stephan
0132417d3a fix 2021-12-20 19:12:14 +01:00
Stephan
2376e90494 fix 2021-12-20 19:08:45 +01:00
Stephan
af84310aa0 fix 2021-12-20 19:07:11 +01:00
Stephan
02c3f02a25 fix 2021-12-20 19:02:46 +01:00
Stephan
4661a20940 fix 2021-12-20 14:19:30 +01:00
Stephan
d1aba02e40 fix 2021-12-20 13:01:12 +01:00
Stephan
87f5690188 fix 2021-12-16 16:07:45 +01:00
Stephan
f9c717556d fix 2021-12-16 16:06:06 +01:00
Stephan
b7be07cd11 fix 2021-12-16 16:04:40 +01:00
Stephan
bccd87fe75 fix 2021-12-16 15:51:58 +01:00
Stephan
3855041754 fix 2021-12-16 14:49:26 +01:00
Stephan
72c147effd fix 2021-12-16 14:09:19 +01:00
Stephan
241f21c28b fix 2021-12-16 14:06:20 +01:00
Stephan
7035d63440 fix 2021-12-16 14:03:52 +01:00
Stephan
561e1dcfde fix 2021-12-16 13:59:02 +01:00
Stephan
04327b45b0 fix 2021-12-16 13:55:52 +01:00
Stephan
435be3b612 fix 2021-12-16 13:54:27 +01:00
Stephan
ef71b6110f fix 2021-12-16 13:51:58 +01:00
Stephan
4611d58702 fix 2021-12-16 13:48:06 +01:00
Stephan
6f0311f20f fix 2021-12-16 13:44:14 +01:00
Stephan
7b4d73a9db fix 2021-12-16 13:39:46 +01:00
Stephan
5144a4ebeb fix 2021-12-16 13:00:12 +01:00
Stephan
6d27d4d607 fix 2021-12-16 12:56:17 +01:00
Stephan
6349403466 fix 2021-12-16 12:54:38 +01:00
Stephan
9e6aad4060 fix 2021-12-16 12:50:40 +01:00
Stephan
3356fe58aa fix 2021-12-16 12:49:06 +01:00
Stephan
4bf2ae8436 fix 2021-12-16 12:47:47 +01:00
Stephan
a748f6afa7 Merge remote-tracking branch 'origin/master' 2021-12-16 12:46:23 +01:00
Stephan
d4fe53e46b test assign to project 2021-12-16 12:46:08 +01:00
Stephan
879fa90155 Merge pull request #64 from M0stafa-Fawzy/master
Merge: Add files via upload
Looks good to me now!
2021-12-13 10:26:19 +01:00
Mostafa Fawzy
912747b966 Update 6.txt 2021-12-12 23:35:15 +02:00
Mostafa Fawzy
23a0258b4a Merge pull request #1 from M0stafa-Fawzy/M0stafa-Fawzy-patch-1
Add files via upload
2021-12-12 03:52:48 +02:00
Mostafa Fawzy
2210711e57 Add files via upload 2021-12-12 03:51:28 +02:00
Mostafa Fawzy
1a1db12656 Add files via upload 2021-12-12 03:44:10 +02:00
Stephan
43287ec9cf exp 2021-12-10 18:56:12 +01:00
Stephan
4bc423721a exp 2021-12-10 18:09:50 +01:00
Stephan
5ef1917f61 exp 2021-12-10 18:04:43 +01:00
Stephan
3b98325435 exp 2021-12-10 17:53:40 +01:00
Stephan
7688e0cbc7 exp 2021-12-10 17:48:01 +01:00
Stephan
5595250e09 exp 2021-12-10 17:42:04 +01:00
Stephan
4e8f7f271f exp 2021-12-10 17:39:59 +01:00
Stephan
f2db146379 exp 2021-12-10 17:35:15 +01:00
Stephan
11e6e12f60 exp 2021-12-10 17:32:45 +01:00
Stephan
56827f467a rename 2021-12-10 17:30:51 +01:00
Stephan
34a05d36a6 exp 2021-12-10 17:29:04 +01:00
Stephan
bb1ee93cb9 exp 2021-12-10 17:27:14 +01:00
Stephan
de64657f2c exp 2021-12-10 16:40:40 +01:00
12 changed files with 433 additions and 33 deletions

View File

@@ -156,11 +156,22 @@
}
},
"node_modules/node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/once": {
@@ -171,6 +182,11 @@
"wrappy": "1"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
@@ -184,6 +200,20 @@
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
@@ -326,9 +356,12 @@
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
},
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
"requires": {
"whatwg-url": "^5.0.0"
}
},
"once": {
"version": "1.4.0",
@@ -338,6 +371,11 @@
"wrappy": "1"
}
},
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
@@ -348,6 +386,20 @@
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w=="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

162
.github/workflows/assign-milestones.js vendored Normal file
View File

@@ -0,0 +1,162 @@
// get the project
// check if the name matches a version x.y or x.y.z
// created
// check that there is a corresponding milestone
// else create that milestone
// and assign the issue to the milestone
// deleted
// get the issue
// if issue is not closed,
// remove issue from milestone, if any
// an issue or PR actually becomes a card (or, a card is actually created...) when
// it's move to a project column for the first time - being assigned to the project
// and showing in project's backlog is not enough.
module.exports = async ({github, context, core}) => {
const restapi = github.rest
function last1(s) {
const pos = s.lastIndexOf('/')
return s.substring(pos + 1)
}
function last2(s) {
const pos1 = s.lastIndexOf('/')
const pos2 = s.lastIndexOf('/', pos1-1)
return [ s.substring(pos2 + 1, pos1), s.substring(pos1 + 1) ]
}
function firstOrDefault(items, predicate) {
for (const item of items) {
if (predicate(item)) {
return item
}
}
return null
}
// insanely enough, due to the total lack of documentation, this
// is the best way one can figure out what exactly we are getting
console.log(github)
console.log(context)
console.log(context.payload)
//console.log(`event: ${github.event_name}/${github.event.action}`)
// get and validate the event name
const eventName = context.eventName
if (eventName != 'project_card') {
return
}
// get and validate the event action
const eventAction = context.payload.action
if (eventAction != 'created' && eventAction != 'deleted') {
return
}
console.log(`event: ${eventName}/${eventAction}`)
const columnId = context.payload.project_card.column_id
const columnResponse = await restapi.projects.getColumn({
column_id: columnId
})
const column = columnResponse.data
console.log(column)
const projectId = last1(column.project_url)
const projectResponse = await restapi.projects.get({
project_id: projectId
});
const project = projectResponse.data
console.log(project)
const projectName = project.name
// -- when a card is deleted it cannot be fetched!
//const cardId = context.payload.project_card.id
//const cardResponse = await restapi.projects.getCard({
// card_id: cardId
//})
//const card = cardResponse.data
//console.log(card)
//const [ itemType, itemNumber ] = last2(card.content_url)
const [ itemType, itemNumber ] = last2(context.payload.project_card.content_url)
const isIssue = itemType == 'issues'
const isPull = itemType == 'pulls'
if (!isIssue && !isPull) {
core.setFailed(`Unsupported item type ${itemType}`)
return
}
const itemApi = isIssue ? restapi.issues : restapi.pulls
var request = {
owner: context.repo.owner,
repo: context.repo.repo
}
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
console.log(request)
const itemResponse = await itemApi.get(request)
const item = itemResponse.data
console.log(item)
const itemId = item.id
const itemMilestone = item.milestone
console.log(`item: ${itemType}/${itemId} milestone: ${itemMilestone == null ? '<none>' : itemMilestone}`)
if (eventAction == 'created') {
console.log('add or update milestone of issue/pull of created card')
const milestonesResponse = await restapi.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo
})
const milestones = milestonesResponse.data
console.log(milestones)
var milestone = firstOrDefault(milestones, (x) => x.title == projectName)
if (!milestone) {
console.log(`create milestone '${projectName}'`)
const milestoneResponse = await restapi.issues.createMilestone({
owner: context.repo.owner,
repo: context.repo.repo,
title: projectName
})
milestone = milestoneResponse.data
}
const milestoneNumber = milestone.number
if (!item.milestone || item.milestone.number != milestoneNumber)
{
request = {
owner: context.repo.owner,
repo: context.repo.repo,
milestone: milestoneNumber
}
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
await itemApi.update(request)
}
}
else if (eventAction == 'deleted') {
if (itemMilestone) {
console.log('remove milestone from issue/pull of deleted card')
request = {
owner: context.repo.owner,
repo: context.repo.repo
}
request[isIssue ? 'issue_number' : 'pull_number'] = itemNumber
request.milestone = null
await itemApi.update(request)
}
else {
console.log('deleted card had no milestone')
}
}
else {
console.log(`nothing to do for evet action ${eventAction}`)
}
}

46
.github/workflows/assign-milestones.yml vendored Normal file
View File

@@ -0,0 +1,46 @@
name: Assign Milestones
on:
project_card:
# ignore: moved, converted, edited
types: [ created, deleted, moved ] # FIXME temp
jobs:
assign:
runs-on: ubuntu-latest
name: Assign
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Assign
uses: actions/github-script@v5
with:
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }}
script: |
// see https://github.com/actions/github-script
//
// note: 'github' below is not the same as the yml-level 'github' context
// see https://docs.github.com/en/actions/learn-github-actions/contexts
// for yml contexts
//
// github A pre-authenticated octokit/rest.js client with pagination plugins
// .rest The REST API (e.g. github.rest.issues.get(...) gets an issue)
// .request
// .paginate
// .graphql
// context An object containing the context of the workflow run
// see https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts
// core A reference to the @actions/core package
// glob A reference to the @actions/glob package
// io A reference to the @actions/io package
// exec A reference to the @actions/exec package
// require A proxy wrapper around the normal Node.js require to enable requiring relative paths
// (relative to the current working directory) + requiring npm packages installed in the
// current working directory.
const script = require('./.github/workflows/assign-milestones.js')
await script({github, context, core})

137
.github/workflows/assign-to-project.yml vendored Normal file
View File

@@ -0,0 +1,137 @@
name: Assign PRs to Project
on:
#issues:
# types: [ opened ]
#pull_request:
# types: [ opened ]
# important to use pull_request_target here to run code from 'main' not the PR,
# with access to PAT - and safe permission to make changes to the project
pull_request_target:
types: [ opened, labeled ]
# github-script: https://github.com/actions/github-script
# -> points to github rest (octokit) reference doc
# github PAT: https://github.com/settings/tokens
# must have full repo access
# FIXME how can I prevent a user from creating a PR and stealing my token?
# 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
# curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ghp_..." https://api.github.com/projects/1/columns?owner=zpqrtbnk&repo=test-repo
# curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ghp_..." https://api.github.com/projects/1/columns?owner=zpqrtbnk-alt&repo=test-repo-alt
jobs:
assign:
runs-on: ubuntu-latest
name: Assign
steps:
- name: Assign
uses: actions/github-script@v4
with:
github-token: ${{ secrets.MY_GITHUB_TOKEN_TESTREPO }}
script: |
//const project_name = 'The API Team Board'
//const column_name = 'Drafting'
const project_name = 'test-project'
const column_name = 'To do'
function firstOrDefault(items, predicate) {
for (const item of items) {
if (predicate(item)) {
return item
}
}
return null
}
// find the project
console.log('find project...')
const projects = await github.projects.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo
})
console.log(`retrieved ${projects.data.length} projects.`)
const project = firstOrDefault(projects.data, (x) => x.name === project_name)
if (!project) {
core.setFailed(`Failed to find project "${project_name}".`)
return
}
else {
console.log(`project '${project_name}' id: ${project.id}.`)
}
// find the column
console.log('find column...')
const columns = await github.projects.listColumns({
project_id: project.id
})
console.log(`retrieved ${columns.data.length} columns.`)
const column = firstOrDefault(columns.data, (x) => x.name === column_name)
if (!column) {
core.setFailed(`Failed to find column "${column_name}" in project ${project.name}.`)
return
}
else {
console.log(`column '${column_name}' id: ${column.id}.`)
}
// determine content type
console.log('determine content type...')
const event_name = context.eventName
var content_type = null
var item_number = null
var item_id = null
if (event_name === 'issues') {
content_type = 'Issue'
// temp!
core.setFailed(`Unsupported: issue.`)
return
item_number = context.issue.number
item_id = context.issue.id
}
if (event_name === 'pull_request' || event_name === 'pull_request_target') {
content_type = 'PullRequest'
item_number = context.payload.pull_request.number
item_id = context.payload.pull_request.id
}
if (!content_type) {
core.setFailed(`Unexpected event name "${event_name}".`)
return
}
else {
console.log(`content type: ${content_type}.`)
}
// get the item
console.log('get the item...')
const item = await github.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item_number
})
if (!item) {
core.setFailed(`Failed to get item ${item_number}.`)
return
}
else {
console.log(`${content_type} #${context.issue.number} id: ${item.data.id}.`)
if (item_id === item.data.id) {
console.log(`item_id: ${item_id}`)
}
else {
console.log(`but 'context.payload' provides item_id: ${item_id} and meh?`)
}
}
console.log('create the card...')
console.log(`in column ${column.id} for item ${item_id} of type ${content_type}`)
await github.projects.createCard({
column_id: column.id,
//note:,
content_id: item_id,
content_type: content_type
})
console.log('created')

View File

@@ -1,19 +0,0 @@
name: Manually Do Something
on: workflow_dispatch
jobs:
job:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/')
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Do Something
run: |
version="${${{ github.ref }}:19}" # trim starting 'refs/heads/release/' (19 chars)
echo "Tag ref ${{ github.ref }} as v$version"
git tag v$version
git config user.email "github-actions@zpqrtbnk.net"
git config user.name "GitHub Actions (Do Something)"
git push --tags

15
.github/workflows/publish-release.js vendored Normal file
View File

@@ -0,0 +1,15 @@
module.exports = async ({github, context, core}) => {
const restapi = github.rest
function firstOrDefault(items, predicate) {
for (const item of items) {
if (predicate(item)) {
return item
}
}
return null
}
console.log("script")
}

14
.github/workflows/publish-release.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
name: Publish Release
on: workflow_dispatch
jobs:
job:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/') # 19 leading chars
steps:
- name: Validate the release
uses: actions/github-script@v5
with:
script: |
const script = require('./.github/workflows/publish-release.js')
console.log(script)

View File

@@ -1,3 +0,0 @@
this is a new file only in my branch
changing something that won't conflict in master

View File

@@ -1 +0,0 @@
duh

3
e.txt
View File

@@ -1,3 +0,0 @@
e
MiNor Change

View File

@@ -1 +0,0 @@
foo

1
test.txt Normal file
View File

@@ -0,0 +1 @@
test