Skip to content

Commit 5ea9046

Browse files
authored
Merge pull request #1 from im-open/initial-commit
Create Action
2 parents b1a4330 + be06a3c commit 5ea9046

File tree

12 files changed

+47178
-1934
lines changed

12 files changed

+47178
-1934
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @im-open/infra-purple
1+
* @im-open/swat

.github/workflows/build-and-review-pr.yml

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,51 +49,14 @@ jobs:
4949
# The files that contain source code for the action. Only files that affect the action's execution
5050
# should be included like action.yml or package.json. Do not include files like README.md or .gitignore.
5151
# Files do not need to be explicitly provided here if they fall under one of the dirs in dirs-with-code.
52-
# The format of this input is a comma-separated string.
5352
# ** This value must match the same files-with-code argument specified in increment-version-on-merge.yml.
54-
files-with-code: 'action.yml,package.json,package-lock.json' # TODO: Update if there are additional files or scripts.
53+
files-with-code: 'action.yml,package.json,package-lock.json'
5554

5655
# The directories that contain source code for the action. Only dirs with files that affect the action's
5756
# execution should be included like src or dist. Do not include dirs like .github or node_modules.
58-
# The format of this input is a comma-separated string.
5957
# ** This value must match the same dirs-with-code argument specified in increment-version-on-merge.yml.
60-
dirs-with-code: 'src,dist' # TODO: Update if there are additional directories with code for the action.
58+
dirs-with-code: 'src,dist'
6159

6260
# The npm script to run to build the action. This is typically 'npm run build' if the
6361
# action needs to be compiled. For composite-run-steps actions this is typically empty.
64-
build-command: 'npm run build' # TODO: Update if a different command is used to build/recompile/format the action
65-
66-
test:
67-
runs-on: ubuntu-latest
68-
steps:
69-
#--------------------------------------
70-
# Setup
71-
#--------------------------------------
72-
- uses: actions/checkout@v3
73-
# TODO: add any additional steps needed to setup the test scenarios
74-
75-
# TODO: Replace with the scenarios needed to test this action
76-
77-
#--------------------------------------
78-
# SCENARIO 1
79-
#--------------------------------------
80-
- name: '-------------------------------------------------------------------------------------------------------'
81-
run: echo ""
82-
83-
- name: When the repo is 'im-open/javascript-action-template'
84-
if: always()
85-
id: repo-check
86-
run: |
87-
if [ "${{ github.repository }}" != "im-open/javascript-action-template" ]; then
88-
exit 1
89-
else
90-
echo "SUCCESS=true" >> "$GITHUB_OUTPUT"
91-
fi
92-
93-
- name: Then the outcome should be success
94-
if: always()
95-
run: ./test/assert-values-match.sh --name "step outcome" --expected "success" --actual "${{ steps.repo-check.outcome }}"
96-
97-
- name: And the SUCCESS output should be true
98-
if: always()
99-
run: ./test/assert-values-match.sh --name "SUCCESS output" --expected "true" --actual "${{ steps.repo-check.outputs.SUCCESS }}"
62+
build-command: 'npm run build'

.github/workflows/increment-version-on-merge.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Increment Version on Merge
22
run-name: "${{ github.event.pull_request.merged && 'Increment version for' || 'Closing' }} PR #${{ github.event.pull_request.number }}"
3-
43
on:
54
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
65
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
@@ -39,12 +38,10 @@ jobs:
3938
# The files that contain source code for the action. Only files that affect the action's execution
4039
# should be included like action.yml or package.json. Do not include files like README.md or .gitignore.
4140
# Files do not need to be explicitly provided here if they fall under one of the dirs in dirs-with-code.
42-
# The format of this input is a comma-separated string.
43-
# ** This value must match the same files-with-code argument specified in build-and-review-pr.yml.
44-
files-with-code: 'action.yml,package.json,package-lock.json' # TODO: Update if there are additional files or scripts.
41+
# ** This value must match the same files-with-code argument specified in increment-version-on-merge.yml.
42+
files-with-code: 'action.yml,package.json,package-lock.json'
4543

4644
# The directories that contain source code for the action. Only dirs with files that affect the action's
4745
# execution should be included like src or dist. Do not include dirs like .github or node_modules.
48-
# The format of this input is a comma-separated string.
49-
# ** This value must match the same dirs-with-code argument specified in build-and-review-pr.yml.
50-
dirs-with-code: 'src,dist' # TODO: Update if there are additional directories with code for the action.
46+
# ** This value must match the same dirs-with-code argument specified in increment-version-on-merge.yml.
47+
dirs-with-code: 'src,dist'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 im-open
3+
Copyright (c) 2024 WTW
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 114 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,119 @@
1-
# javascript-action-template
1+
# get-github-deployments
22

3-
This template can be used to quickly start a new custom js action repository. Click the `Use this template` button at the top to get started.
3+
This action gets a list of GitHub deployments and statuses created by [im-open/create-github-deployment]. It is designed to work with a custom Spotify Backstage GitHub Deployments plugin called [im-open/im-github-deployments].
44

55
## Index <!-- omit in toc -->
66

7-
- [javascript-action-template](#javascript-action-template)
8-
- [Inputs](#inputs)
9-
- [Outputs](#outputs)
10-
- [Usage Examples](#usage-examples)
11-
- [Contributing](#contributing)
12-
- [Incrementing the Version](#incrementing-the-version)
13-
- [Source Code Changes](#source-code-changes)
14-
- [Recompiling Manually](#recompiling-manually)
15-
- [Updating the README.md](#updating-the-readmemd)
16-
- [Tests](#tests)
17-
- [Code of Conduct](#code-of-conduct)
18-
- [License](#license)
19-
20-
## TODOs <!-- omit in toc -->
21-
22-
- README.md
23-
- [ ] Update the Inputs section with the correct action inputs
24-
- [ ] Update the Outputs section with the correct action outputs
25-
- [ ] Update the Usage Example section with the correct usage
26-
- package.json
27-
- [ ] Update the `name` with the new action value
28-
- src/main.js
29-
- [ ] Implement your custom javascript action
30-
- action.yml
31-
- [ ] Fill in the correct name, description, inputs and outputs
32-
- .prettierrc.json
33-
- [ ] Update any preferences you might have
34-
- CODEOWNERS
35-
- [ ] Update as appropriate
36-
- Repository Settings
37-
- [ ] On the *Options* tab check the box to *Automatically delete head branches*
38-
- [ ] On the *Options* tab update the repository's visibility (must be done by an org owner)
39-
- [ ] On the *Branches* tab add a branch protection rule
40-
- [ ] Check *Require pull request reviews before merging*
41-
- [ ] Check *Dismiss stale pull request approvals when new commits are pushed*
42-
- [ ] Check *Require review from Code Owners*
43-
- [ ] Check *Require status checks to pass before merging*
44-
- [ ] Check *Require branches to be up to date before merging*
45-
- [ ] Add `build` to the list of required status checks. This will need to be done after the first `build` workflow runs.
46-
- [ ] Check *Do not allow bypassing the above settings*
47-
- [ ] On the *Manage Access* tab add the appropriate groups
48-
- About Section (accessed on the main page of the repo, click the gear icon to edit)
49-
- [ ] The repo should have a short description of what it is for
50-
- [ ] Add one of the following topic tags:
51-
| Topic Tag | Usage |
52-
|-----------------|------------------------------------------|
53-
| az | For actions related to Azure |
54-
| code | For actions related to building code |
55-
| certs | For actions related to certificates |
56-
| db | For actions related to databases |
57-
| git | For actions related to Git |
58-
| iis | For actions related to IIS |
59-
| microsoft-teams | For actions related to Microsoft Teams |
60-
| svc | For actions related to Windows Services |
61-
| jira | For actions related to Jira |
62-
| meta | For actions related to running workflows |
63-
| pagerduty | For actions related to PagerDuty |
64-
| test | For actions related to testing |
65-
| tf | For actions related to Terraform |
66-
- [ ] Add any additional topics for an action if they apply
67-
- [ ] The Packages and Environments boxes can be unchecked
68-
- Search for any remaining TODOs and address them.
7+
- [Inputs](#inputs)
8+
- [Outputs](#outputs)
9+
- [Usage Example](#usage-example)
10+
- [Return Example](#return-example)
11+
- [Contributing](#contributing)
12+
- [Incrementing the Version](#incrementing-the-version)
13+
- [Source Code Changes](#source-code-changes)
14+
- [Recompiling Manually](#recompiling-manually)
15+
- [Updating the README.md](#updating-the-readmemd)
16+
- [Code of Conduct](#code-of-conduct)
17+
- [License](#license)
18+
6919

7020
## Inputs
7121

72-
| Parameter | Is Required | Default | Description |
73-
|-----------|-------------|---------|-----------------------|
74-
| `input` | true | | Description goes here |
22+
| Parameter | Is Required | Description |
23+
| ------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
24+
| `token` | true | A token with `deployments:read` and `contents:read` to get the deployments and release reference data. |
25+
| `environment` | true | The name of a GitHub environment the release was deployed to, i.e. [Dev\|QA\|Stage\|Demo\|UAT\|Prod]. It will be used to filter deployment objects. |
26+
| `entity` | true | The entity that is deployed, i.e. "proj-app", "proj-infrastruction" or "proj-db" |
27+
| `instance` | true | A freeform identifier to distinguish separately deployed instances of the entity in the same environment. Typical uses would be to name a slot and/or region, e.g "NA26", "NA26-slot1", "NA27-blue", "Primary", "Secondary", etc. |
7528

7629
## Outputs
7730

78-
| Output | Description | Possible Values |
79-
|----------|-----------------------|-----------------|
80-
| `output` | Description goes here | |
81-
82-
## Usage Examples
31+
| Value | Description |
32+
| ----------- | ----------------------------------------------------- |
33+
| deployments | A list of deployments by `environment` and `instance` |
34+
35+
## Usage Example
36+
37+
```yaml
38+
name: Get Environment Instance Deployments
39+
on:
40+
workflow_dispatch:
41+
environment:
42+
description: The testing environment
43+
required: true
44+
type: choice
45+
options:
46+
- Dev
47+
- QA
48+
inputs:
49+
instance:
50+
description: The instance to deploy to
51+
required: true
52+
type: choice
53+
options:
54+
- Primary-Test-Slot1
55+
- Primary-Test-Slot2
56+
- Secondary-Test-Slot1
57+
- Secondary-Test-Slot2
58+
59+
# Permissions needed to get GitHub deployments & status objects
60+
permissions:
61+
deployments: read
62+
contents: read
8363

84-
```yml
8564
jobs:
86-
jobname: # TODO: fix the job name
87-
runs-on: ubuntu-20.04
65+
environment: ${{ github.event.inputs.environment }}
66+
deploy-different-ways:
67+
runs-on: [ubuntu-20.04]
68+
8869
steps:
89-
- uses: actions/checkout@v3
70+
get-deployments:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Get Deployments
74+
id: get-deployments
75+
uses: im-open/get-github-deployments@v1.0.0
76+
with:
77+
token: ${{ secrets.GITHUB_TOKEN }}
78+
environment: ${{ github.event.inputs.environment }}
79+
entity: get-github-deployments
80+
instance: ${{ github.event.inputs.instance }}
81+
82+
- name: Display Deployments
83+
id: display-deployments
84+
run: echo "${{ steps.get-deployments.outputs.deployments }}"
85+
...
86+
```
9087

91-
- name: ''
92-
uses: im-open/thisrepo@v1.0.0 # TODO: fix the action name
93-
with:
94-
input: ''
88+
*_Make sure your workflow has the `permissions.contents` and `permissions.deployments` set to `read`._*
89+
90+
### Return Example
91+
92+
```json
93+
[
94+
{
95+
"ref": "v1.2.1",
96+
"status": "SUCCESS",
97+
"description": "It worked!",
98+
"workflow_actor": "gh-user",
99+
"created_at": "2024-01-31T17:21:08.000+00:00"
100+
},
101+
{
102+
"ref": "v1.2.3",
103+
"status": "INACTIVE",
104+
"description": "Inactivated by workflow",
105+
"workflow_actor": "gh-user",
106+
"created_at": "2024-01-31T17:21:08.000+00:00"
107+
},
108+
{
109+
"ref": "v1.2.2",
110+
"status": "INACTIVE",
111+
"description": "Inactivated by workflow",
112+
"workflow_actor": "gh-user",
113+
"created_at": "2024-01-30T23:26:19.000+00:00"
114+
},
115+
...
116+
]
95117
```
96118

97119
## Contributing
@@ -102,14 +124,13 @@ When creating PRs, please review the following guidelines:
102124
- [ ] At least one of the commit messages contains the appropriate `+semver:` keywords listed under [Incrementing the Version] for major and minor increments.
103125
- [ ] The action has been recompiled. See [Recompiling Manually] for details.
104126
- [ ] The README.md has been updated with the latest version of the action. See [Updating the README.md] for details.
105-
- [ ] Any tests in the [build-and-review-pr] workflow are passing
106127

107128
### Incrementing the Version
108129

109130
This repo uses [git-version-lite] in its workflows to examine commit messages to determine whether to perform a major, minor or patch increment on merge if [source code] changes have been made. The following table provides the fragment that should be included in a commit message to active different increment strategies.
110131

111132
| Increment Type | Commit Message Fragment |
112-
|----------------|---------------------------------------------|
133+
| -------------- | ------------------------------------------- |
113134
| major | +semver:breaking |
114135
| major | +semver:major |
115136
| minor | +semver:feature |
@@ -118,7 +139,7 @@ This repo uses [git-version-lite] in its workflows to examine commit messages to
118139

119140
### Source Code Changes
120141

121-
The files and directories that are considered source code are listed in the `files-with-code` and `dirs-with-code` arguments in both the [build-and-review-pr] and [increment-version-on-merge] workflows.
142+
The files and directories that are considered source code are listed in the `files-with-code` and `dirs-with-code` arguments in both the [build-and-review-pr] and [increment-version-on-merge] workflows.
122143

123144
If a PR contains source code changes, the README.md should be updated with the latest action version and the action should be recompiled. The [build-and-review-pr] workflow will ensure these steps are performed when they are required. The workflow will provide instructions for completing these steps if the PR Author does not initially complete them.
124145

@@ -137,25 +158,28 @@ npm run build
137158

138159
If changes are made to the action's [source code], the [usage examples] section of this file should be updated with the next version of the action. Each instance of this action should be updated. This helps users know what the latest tag is without having to navigate to the Tags page of the repository. See [Incrementing the Version] for details on how to determine what the next version will be or consult the first workflow run for the PR which will also calculate the next version.
139160

140-
### Tests
141-
142-
The build and review PR workflow includes tests which are linked to a status check. That status check needs to succeed before a PR is merged to the default branch. When a PR comes from a branch, there should not be any issues running the tests. When a PR comes from a fork, tests may not have the required permissions or access to run since the `GITHUB_TOKEN` only has `read` access set for all scopes. Also, forks cannot access other secrets in the repository. In these scenarios, a fork may need to be merged into an intermediate branch by the repository owners to ensure the tests run successfully prior to merging to the default branch.
143-
144161
## Code of Conduct
145162

146163
This project has adopted the [im-open's Code of Conduct](https://github.com/im-open/.github/blob/main/CODE_OF_CONDUCT.md).
147164

148165
## License
149166

150-
Copyright &copy; 2023, Extend Health, LLC. Code released under the [MIT license](LICENSE).
167+
Copyright &copy; 2024, Extend Health, LLC. Code released under the [MIT license](LICENSE).
151168

152-
<!-- Links -->
169+
<!-- Links -->
170+
[im-open/create-github-deployment]: https://github.com/im-open/create-github-deployment
171+
[im-open/im-github-deployments]: https://github.com/im-open/im-github-deployments
172+
[Backstage Software Catalog]: https://backstage.io/docs/features/software-catalog/
153173
[Incrementing the Version]: #incrementing-the-version
154174
[Recompiling Manually]: #recompiling-manually
155-
[source code]: #source-code-changes
156175
[Updating the README.md]: #updating-the-readmemd
176+
[source code]: #source-code-changes
157177
[usage examples]: #usage-examples
158178
[build-and-review-pr]: ./.github/workflows/build-and-review-pr.yml
159179
[increment-version-on-merge]: ./.github/workflows/increment-version-on-merge.yml
160180
[esbuild]: https://esbuild.github.io/getting-started/#bundling-for-node
161181
[git-version-lite]: https://github.com/im-open/git-version-lite
182+
[the board]: https://github.com/im-open/inactivate-github-deployment/projects/1
183+
[cleanup-deployment-board]: https://github.com/im-open/cleanup-deployment-board
184+
185+
[im-github-deployments]: https://github.com/im-open/im-github-deployments

action.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
name: 'JavaScript Action Template'
2-
3-
description: 'Add description here'
1+
name: Get GitHub Deployments
2+
description: Get GitHub a list of deployments that have been created by im-open/create-github-deployment.
43

54
inputs:
6-
input-1:
7-
description: 'Add a description here'
5+
token:
6+
description: A token with `deployments:read` and `contents:read` to get the deployments and release reference data.
7+
required: true
8+
environment:
9+
description: The name of a GitHub environment the release was deployed to, i.e. [Dev\|QA\|Stage\|Demo\|UAT\|Prod]. It will be used to filter deployment objects.
10+
required: true
11+
entity:
12+
description: The entity that is deployed, i.e. "proj-app", "proj-infrastruction" or "proj-db"
13+
required: true
14+
instance:
15+
description: A freeform identifier to distinguish separately deployed instances of the entity in the same environment. Typical uses would be to name a slot and/or region, e.g "NA26", "NA26-slot1", "NA27-blue", "Primary", "Secondary", etc.
816
required: true
9-
10-
outputs:
11-
output-1:
12-
description: 'Add a description here'
1317

1418
runs:
15-
using: 'node16'
16-
main: 'dist/index.js'
19+
using: node20
20+
main: dist/index.js

0 commit comments

Comments
 (0)