Skip to content

Commit 316672f

Browse files
committed
setup github action
1 parent c3a5846 commit 316672f

4 files changed

Lines changed: 205 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#########################################################################
2+
# Dependabot configuration file
3+
#########################################################################
4+
5+
version: 2
6+
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
# Workflow files stored in the
10+
# default location of `.github/workflows`
11+
directory: "/"
12+
schedule:
13+
interval: "weekly"
14+
day: "friday"
15+
time: "18:00" # UTC
16+
open-pull-requests-limit: 20
17+
commit-message:
18+
prefix: "Upgrade: [dependabot] - "
19+
20+
###################################
21+
# NPM workspace ##################
22+
###################################
23+
- package-ecosystem: "npm"
24+
directory: "/"
25+
schedule:
26+
interval: "weekly"
27+
day: "friday"
28+
time: "18:00"
29+
open-pull-requests-limit: 20
30+
versioning-strategy: increase
31+
commit-message:
32+
prefix: "Upgrade: [dependabot] - "
33+
34+
###################################
35+
# Poetry #########################
36+
###################################
37+
- package-ecosystem: "pip"
38+
directory: "/"
39+
schedule:
40+
interval: "weekly"
41+
day: "friday"
42+
time: "18:00"
43+
open-pull-requests-limit: 20
44+
versioning-strategy: increase
45+
commit-message:
46+
prefix: "Upgrade: [dependabot] - "

.github/pull_request_template.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Summary
2+
3+
**Remove items from this list if they are not relevant. Remove this line once this has been done**
4+
5+
- Routine Change
6+
- :exclamation: Breaking Change
7+
- :robot: Operational or Infrastructure Change
8+
- :sparkles: New Feature
9+
- :warning: Potential issues that might be caused by this change
10+
11+
### Details
12+
13+
Add any summary information of what is in the change. **Remove this line if you have nothing to add.**
14+
15+
## Pull Request Naming
16+
17+
Pull requests should be named using the following format:
18+
19+
```text
20+
Tag: [AEA-NNNN] - Short description
21+
```
22+
23+
Tag can be one of:
24+
25+
- `Fix` - for a bug fix. (Patch release)
26+
- `Update` - either for a backwards-compatible enhancement or for a rule change that adds reported problems. (Patch release)
27+
- `New` - implemented a new feature. (Minor release)
28+
- `Breaking` - for a backwards-incompatible enhancement or feature. (Major release)
29+
- `Docs` - changes to documentation only. (Patch release)
30+
- `Build` - changes to build process only. (No release)
31+
- `Upgrade` - for a dependency upgrade. (Patch release)
32+
- `Chore` - for refactoring, adding tests, etc. (anything that isn't user-facing). (Patch release)
33+
34+
If the current release is x.y.z then
35+
- a patch release increases z by 1
36+
- a minor release increases y by 1
37+
- a major release increases x by 1
38+
39+
Correct tagging is necessary for our automated versioning and release process.
40+
41+
The description of your pull request will be used as the commit message for the merge, and also be included in the changelog. Please ensure that your title is sufficiently descriptive.
42+
43+
### Rerunning Checks
44+
45+
If you need to rename your pull request, you can restart the checks by either:
46+
47+
- Closing and reopening the pull request
48+
- pushing an empty commit
49+
```bash
50+
git commit --allow-empty -m 'trigger build'
51+
git push
52+
```
53+
- Amend your last commit and force push to the branch
54+
```bash
55+
git commit --amend --no-edit
56+
git push --force
57+
```
58+
59+
Rerunning the checks from within the pull request will not use the updated title.

.github/workflows/pull_request.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: deploy_pr
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
env:
8+
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
9+
10+
jobs:
11+
dependabot-auto-approve-and-merge:
12+
needs: quality_checks
13+
uses: NHSDigital/eps-common-workflows/.github/workflows/dependabot-auto-approve-and-merge.yml@2b3ddfd1e59daf9905522d0140c6cd08e2547432
14+
secrets:
15+
AUTOMERGE_APP_ID: ${{ secrets.AUTOMERGE_APP_ID }}
16+
AUTOMERGE_PEM: ${{ secrets.AUTOMERGE_PEM }}
17+
18+
get_asdf_version:
19+
runs-on: ubuntu-22.04
20+
outputs:
21+
asdf_version: ${{ steps.asdf-version.outputs.version }}
22+
tag_format: ${{ steps.load-config.outputs.TAG_FORMAT }}
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
26+
27+
- name: Get asdf version
28+
id: asdf-version
29+
run: echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
30+
- name: Load config value
31+
id: load-config
32+
run: |
33+
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
34+
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
35+
36+
quality_checks:
37+
uses: NHSDigital/eps-common-workflows/.github/workflows/quality-checks.yml@trivy
38+
needs: [get_asdf_version]
39+
with:
40+
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
41+
secrets:
42+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43+
44+
pr_title_format_check:
45+
uses: NHSDigital/eps-common-workflows/.github/workflows/pr_title_check.yml@2b3ddfd1e59daf9905522d0140c6cd08e2547432
46+
47+
get_issue_number:
48+
runs-on: ubuntu-22.04
49+
needs: quality_checks
50+
outputs:
51+
issue_number: ${{ steps.get_issue_number.outputs.result }}
52+
version: ${{ steps.get_issue_number.outputs.version_number }}
53+
54+
steps:
55+
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd
56+
name: get issue number
57+
id: get_issue_number
58+
with:
59+
script: |
60+
if (context.issue.number) {
61+
// Return issue number if present
62+
return context.issue.number;
63+
} else {
64+
// Otherwise return issue number from commit
65+
return (
66+
await github.rest.repos.listPullRequestsAssociatedWithCommit({
67+
commit_sha: context.sha,
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
})
71+
).data[0].number;
72+
}
73+
result-encoding: string
74+
75+
get_commit_id:
76+
runs-on: ubuntu-22.04
77+
outputs:
78+
commit_id: ${{ steps.commit_id.outputs.commit_id }}
79+
sha_short: ${{ steps.commit_id.outputs.sha_short }}
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8
84+
with:
85+
ref: ${{ env.BRANCH_NAME }}
86+
87+
- name: Get Commit ID
88+
id: commit_id
89+
run: |
90+
# echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
91+
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
92+
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,11 @@ scan-base-image:
3131
--ignorefile .trivyignore.yaml \
3232
--exit-code 1 \
3333
--format table ${IMAGE_NAME}
34+
35+
lint: lint-githubactions
36+
37+
test:
38+
echo "Not implemented"
39+
40+
lint-githubactions:
41+
actionlint

0 commit comments

Comments
 (0)