Skip to content

Commit

Permalink
Merge pull request #142 from crazy-max/baseref-global-expr
Browse files Browse the repository at this point in the history
`base_ref` global expression
  • Loading branch information
crazy-max authored Oct 22, 2021
2 parents a287d15 + 09666f9 commit 110426b
Show file tree
Hide file tree
Showing 11 changed files with 929 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/__tests__/fixtures/** -linguist-detectable
/dist/** linguist-generated=true
/lib/** linguist-generated=true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ attributes are available:
| `{{branch}}` | `master` |
| `{{tag}}` | `v1.2.3` |
| `{{sha}}` | `90dd603` |
| `{{base_ref}}` | `master` |
| `{{date 'YYYYMMDD'}}` | `20210326` |

```yaml
Expand Down
2 changes: 1 addition & 1 deletion __tests__/fixtures/event_pull_request.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=master
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_e00a951d-2585-4fac-b085-459d80e69a2f
GITHUB_EVENT_NAME=pull_request
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_EVENT_PATH=./__tests__/fixtures/event_pull_request.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=pr
GITHUB_JOB=event
Expand Down
488 changes: 488 additions & 0 deletions __tests__/fixtures/event_pull_request.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __tests__/fixtures/event_push.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_89a016e8-e5b7-4039-a67e-c8da08f87a0c
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_EVENT_PATH=./__tests__/fixtures/event_push.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
Expand Down
181 changes: 181 additions & 0 deletions __tests__/fixtures/event_push.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"after": "ce1a91a20f9e2c064bcd76a7b95e091f831cf653",
"base_ref": null,
"before": "b0d66d13d5e8c795e0fc4b6c732b6b521807eca7",
"commits": [
{
"author": {
"email": "crazy-max@users.noreply.github.com",
"name": "CrazyMax",
"username": "crazy-max"
},
"committer": {
"email": "crazy-max@users.noreply.github.com",
"name": "CrazyMax",
"username": "crazy-max"
},
"distinct": true,
"id": "ce1a91a20f9e2c064bcd76a7b95e091f831cf653",
"message": "Fix workflow",
"timestamp": "2021-10-21T23:44:33+02:00",
"tree_id": "8e46bf0c7fd95050deb02b11f0bc8c475c7428f3",
"url": "https://github.com/crazy-max/test-docker-action/commit/ce1a91a20f9e2c064bcd76a7b95e091f831cf653"
}
],
"compare": "https://github.com/crazy-max/test-docker-action/compare/b0d66d13d5e8...ce1a91a20f9e",
"created": false,
"deleted": false,
"forced": false,
"head_commit": {
"author": {
"email": "crazy-max@users.noreply.github.com",
"name": "CrazyMax",
"username": "crazy-max"
},
"committer": {
"email": "crazy-max@users.noreply.github.com",
"name": "CrazyMax",
"username": "crazy-max"
},
"distinct": true,
"id": "ce1a91a20f9e2c064bcd76a7b95e091f831cf653",
"message": "Fix workflow",
"timestamp": "2021-10-21T23:44:33+02:00",
"tree_id": "8e46bf0c7fd95050deb02b11f0bc8c475c7428f3",
"url": "https://github.com/crazy-max/test-docker-action/commit/ce1a91a20f9e2c064bcd76a7b95e091f831cf653"
},
"pusher": {
"email": "crazy-max@users.noreply.github.com",
"name": "crazy-max"
},
"ref": "refs/heads/master",
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/crazy-max/test-docker-action/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/crazy-max/test-docker-action/assignees{/user}",
"blobs_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/crazy-max/test-docker-action/branches{/branch}",
"clone_url": "https://github.com/crazy-max/test-docker-action.git",
"collaborators_url": "https://api.github.com/repos/crazy-max/test-docker-action/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/crazy-max/test-docker-action/comments{/number}",
"commits_url": "https://api.github.com/repos/crazy-max/test-docker-action/commits{/sha}",
"compare_url": "https://api.github.com/repos/crazy-max/test-docker-action/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/crazy-max/test-docker-action/contents/{+path}",
"contributors_url": "https://api.github.com/repos/crazy-max/test-docker-action/contributors",
"created_at": 1596792180,
"default_branch": "master",
"deployments_url": "https://api.github.com/repos/crazy-max/test-docker-action/deployments",
"description": "Test \"Docker\" Actions",
"disabled": false,
"downloads_url": "https://api.github.com/repos/crazy-max/test-docker-action/downloads",
"events_url": "https://api.github.com/repos/crazy-max/test-docker-action/events",
"fork": false,
"forks": 1,
"forks_count": 1,
"forks_url": "https://api.github.com/repos/crazy-max/test-docker-action/forks",
"full_name": "crazy-max/test-docker-action",
"git_commits_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/tags{/sha}",
"git_url": "git://github.com/crazy-max/test-docker-action.git",
"has_downloads": true,
"has_issues": false,
"has_pages": false,
"has_projects": false,
"has_wiki": false,
"homepage": "",
"hooks_url": "https://api.github.com/repos/crazy-max/test-docker-action/hooks",
"html_url": "https://github.com/crazy-max/test-docker-action",
"id": 285789493,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/crazy-max/test-docker-action/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/crazy-max/test-docker-action/issues/events{/number}",
"issues_url": "https://api.github.com/repos/crazy-max/test-docker-action/issues{/number}",
"keys_url": "https://api.github.com/repos/crazy-max/test-docker-action/keys{/key_id}",
"labels_url": "https://api.github.com/repos/crazy-max/test-docker-action/labels{/name}",
"language": "JavaScript",
"languages_url": "https://api.github.com/repos/crazy-max/test-docker-action/languages",
"license": {
"key": "mit",
"name": "MIT License",
"node_id": "MDc6TGljZW5zZTEz",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit"
},
"master_branch": "master",
"merges_url": "https://api.github.com/repos/crazy-max/test-docker-action/merges",
"milestones_url": "https://api.github.com/repos/crazy-max/test-docker-action/milestones{/number}",
"mirror_url": null,
"name": "test-docker-action",
"node_id": "MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=",
"notifications_url": "https://api.github.com/repos/crazy-max/test-docker-action/notifications{?since,all,participating}",
"open_issues": 4,
"open_issues_count": 4,
"organization": "docker",
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/5429470?v=4",
"email": "info@docker.com",
"events_url": "https://api.github.com/users/crazy-max/events{/privacy}",
"followers_url": "https://api.github.com/users/crazy-max/followers",
"following_url": "https://api.github.com/users/crazy-max/following{/other_user}",
"gists_url": "https://api.github.com/users/crazy-max/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/crazy-max",
"id": 5429470,
"login": "docker",
"name": "docker",
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=",
"organizations_url": "https://api.github.com/users/crazy-max/users",
"received_events_url": "https://api.github.com/users/crazy-max/received_events",
"repos_url": "https://api.github.com/users/crazy-max/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/crazy-max/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/crazy-max/subscriptions",
"type": "Organization",
"url": "https://api.github.com/users/crazy-max"
},
"private": true,
"pulls_url": "https://api.github.com/repos/crazy-max/test-docker-action/pulls{/number}",
"pushed_at": 1634852674,
"releases_url": "https://api.github.com/repos/crazy-max/test-docker-action/releases{/id}",
"size": 714,
"ssh_url": "git@github.com:crazy-max/test-docker-action.git",
"stargazers": 0,
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/crazy-max/test-docker-action/stargazers",
"statuses_url": "https://api.github.com/repos/crazy-max/test-docker-action/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/crazy-max/test-docker-action/subscribers",
"subscription_url": "https://api.github.com/repos/crazy-max/test-docker-action/subscription",
"svn_url": "https://github.com/crazy-max/test-docker-action",
"tags_url": "https://api.github.com/repos/crazy-max/test-docker-action/tags",
"teams_url": "https://api.github.com/repos/crazy-max/test-docker-action/teams",
"topics": [],
"trees_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/trees{/sha}",
"updated_at": "2021-10-21T21:43:51Z",
"url": "https://github.com/crazy-max/test-docker-action",
"visibility": "private",
"watchers": 0,
"watchers_count": 0
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/1951866?v=4",
"events_url": "https://api.github.com/users/crazy-max/events{/privacy}",
"followers_url": "https://api.github.com/users/crazy-max/followers",
"following_url": "https://api.github.com/users/crazy-max/following{/other_user}",
"gists_url": "https://api.github.com/users/crazy-max/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/crazy-max",
"id": 1951866,
"login": "crazy-max",
"node_id": "MDQ6VXNlcjE5NTE4NjY=",
"organizations_url": "https://api.github.com/users/crazy-max/users",
"received_events_url": "https://api.github.com/users/crazy-max/received_events",
"repos_url": "https://api.github.com/users/crazy-max/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/crazy-max/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/crazy-max/subscriptions",
"type": "User",
"url": "https://api.github.com/users/crazy-max"
}
}
2 changes: 1 addition & 1 deletion __tests__/fixtures/event_tag_v1.1.1.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_EVENT_PATH=./__tests__/fixtures/event_tag_v1.1.1.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
Expand Down
162 changes: 162 additions & 0 deletions __tests__/fixtures/event_tag_v1.1.1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
{
"after": "8415a46e9494b78eca43a2dd8dca716b86b9df85",
"base_ref": "refs/heads/master",
"before": "0000000000000000000000000000000000000000",
"commits": [],
"compare": "https://github.com/crazy-max/test-docker-action/compare/v1.1.1",
"created": true,
"deleted": false,
"forced": false,
"head_commit": {
"author": {
"email": "crazy-max@users.noreply.github.com",
"name": "CrazyMax",
"username": "crazy-max"
},
"committer": {
"email": "noreply@github.com",
"name": "GitHub",
"username": "web-flow"
},
"distinct": true,
"id": "8415a46e9494b78eca43a2dd8dca716b86b9df85",
"message": "Trigger notification (#11)\n\nCo-authored-by: CrazyMax <crazy-max@users.noreply.github.com>",
"timestamp": "2021-10-21T23:47:22+02:00",
"tree_id": "8e46bf0c7fd95050deb02b11f0bc8c475c7428f3",
"url": "https://github.com/crazy-max/test-docker-action/commit/8415a46e9494b78eca43a2dd8dca716b86b9df85"
},
"pusher": {
"email": "crazy-max@users.noreply.github.com",
"name": "crazy-max"
},
"ref": "refs/tags/v1.1.1",
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/crazy-max/test-docker-action/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/crazy-max/test-docker-action/assignees{/user}",
"blobs_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/crazy-max/test-docker-action/branches{/branch}",
"clone_url": "https://github.com/crazy-max/test-docker-action.git",
"collaborators_url": "https://api.github.com/repos/crazy-max/test-docker-action/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/crazy-max/test-docker-action/comments{/number}",
"commits_url": "https://api.github.com/repos/crazy-max/test-docker-action/commits{/sha}",
"compare_url": "https://api.github.com/repos/crazy-max/test-docker-action/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/crazy-max/test-docker-action/contents/{+path}",
"contributors_url": "https://api.github.com/repos/crazy-max/test-docker-action/contributors",
"created_at": 1596792180,
"default_branch": "master",
"deployments_url": "https://api.github.com/repos/crazy-max/test-docker-action/deployments",
"description": "Test \"Docker\" Actions",
"disabled": false,
"downloads_url": "https://api.github.com/repos/crazy-max/test-docker-action/downloads",
"events_url": "https://api.github.com/repos/crazy-max/test-docker-action/events",
"fork": false,
"forks": 1,
"forks_count": 1,
"forks_url": "https://api.github.com/repos/crazy-max/test-docker-action/forks",
"full_name": "crazy-max/test-docker-action",
"git_commits_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/tags{/sha}",
"git_url": "git://github.com/crazy-max/test-docker-action.git",
"has_downloads": true,
"has_issues": false,
"has_pages": false,
"has_projects": false,
"has_wiki": false,
"homepage": "",
"hooks_url": "https://api.github.com/repos/crazy-max/test-docker-action/hooks",
"html_url": "https://github.com/crazy-max/test-docker-action",
"id": 285789493,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/crazy-max/test-docker-action/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/crazy-max/test-docker-action/issues/events{/number}",
"issues_url": "https://api.github.com/repos/crazy-max/test-docker-action/issues{/number}",
"keys_url": "https://api.github.com/repos/crazy-max/test-docker-action/keys{/key_id}",
"labels_url": "https://api.github.com/repos/crazy-max/test-docker-action/labels{/name}",
"language": "JavaScript",
"languages_url": "https://api.github.com/repos/crazy-max/test-docker-action/languages",
"license": {
"key": "mit",
"name": "MIT License",
"node_id": "MDc6TGljZW5zZTEz",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit"
},
"master_branch": "master",
"merges_url": "https://api.github.com/repos/crazy-max/test-docker-action/merges",
"milestones_url": "https://api.github.com/repos/crazy-max/test-docker-action/milestones{/number}",
"mirror_url": null,
"name": "test-docker-action",
"node_id": "MDEwOlJlcG9zaXRvcnkyODU3ODk0OTM=",
"notifications_url": "https://api.github.com/repos/crazy-max/test-docker-action/notifications{?since,all,participating}",
"open_issues": 4,
"open_issues_count": 4,
"organization": "docker",
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/5429470?v=4",
"email": "info@docker.com",
"events_url": "https://api.github.com/users/crazy-max/events{/privacy}",
"followers_url": "https://api.github.com/users/crazy-max/followers",
"following_url": "https://api.github.com/users/crazy-max/following{/other_user}",
"gists_url": "https://api.github.com/users/crazy-max/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/crazy-max",
"id": 5429470,
"login": "docker",
"name": "docker",
"node_id": "MDEyOk9yZ2FuaXphdGlvbjU0Mjk0NzA=",
"organizations_url": "https://api.github.com/users/crazy-max/users",
"received_events_url": "https://api.github.com/users/crazy-max/received_events",
"repos_url": "https://api.github.com/users/crazy-max/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/crazy-max/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/crazy-max/subscriptions",
"type": "Organization",
"url": "https://api.github.com/users/crazy-max"
},
"private": true,
"pulls_url": "https://api.github.com/repos/crazy-max/test-docker-action/pulls{/number}",
"pushed_at": 1634852872,
"releases_url": "https://api.github.com/repos/crazy-max/test-docker-action/releases{/id}",
"size": 714,
"ssh_url": "git@github.com:crazy-max/test-docker-action.git",
"stargazers": 0,
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/crazy-max/test-docker-action/stargazers",
"statuses_url": "https://api.github.com/repos/crazy-max/test-docker-action/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/crazy-max/test-docker-action/subscribers",
"subscription_url": "https://api.github.com/repos/crazy-max/test-docker-action/subscription",
"svn_url": "https://github.com/crazy-max/test-docker-action",
"tags_url": "https://api.github.com/repos/crazy-max/test-docker-action/tags",
"teams_url": "https://api.github.com/repos/crazy-max/test-docker-action/teams",
"topics": [],
"trees_url": "https://api.github.com/repos/crazy-max/test-docker-action/git/trees{/sha}",
"updated_at": "2021-10-21T21:47:25Z",
"url": "https://github.com/crazy-max/test-docker-action",
"visibility": "private",
"watchers": 0,
"watchers_count": 0
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/1951866?v=4",
"events_url": "https://api.github.com/users/crazy-max/events{/privacy}",
"followers_url": "https://api.github.com/users/crazy-max/followers",
"following_url": "https://api.github.com/users/crazy-max/following{/other_user}",
"gists_url": "https://api.github.com/users/crazy-max/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/crazy-max",
"id": 1951866,
"login": "crazy-max",
"node_id": "MDQ6VXNlcjE5NTE4NjY=",
"organizations_url": "https://api.github.com/users/crazy-max/users",
"received_events_url": "https://api.github.com/users/crazy-max/received_events",
"repos_url": "https://api.github.com/users/crazy-max/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/crazy-max/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/crazy-max/subscriptions",
"type": "User",
"url": "https://api.github.com/users/crazy-max"
}
}
Loading

0 comments on commit 110426b

Please sign in to comment.