Skip to content

Commit f6b6239

Browse files
authored
Merge pull request #21 from abkfenris/check-version
Check daily for new ERDDAP versions
2 parents 3ce0508 + 4d9e699 commit f6b6239

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Check ERDDAP Version
2+
3+
on:
4+
schedule:
5+
- cron: "0 13 * * 1-5" # Check at 8 am on weekdays
6+
workflow_dispatch:
7+
# Once merged, under actions > Check ERDDAP Version there should be a 'Run Workflow' button which manually trigger a run
8+
9+
10+
11+
jobs:
12+
version:
13+
name: Check the current ERDDAP version
14+
runs-on: ubuntu-18.04
15+
timeout-minutes: 5
16+
if: github.repository == 'axiom-data-science/docker-erddap'
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v1
21+
22+
- name: Get ERDDAP versions, and create an issue if it is out of date
23+
uses: actions/github-script@v3
24+
with:
25+
script: |
26+
const repo_name = "docker-erddap"
27+
const repo_owner = "axiom-data-science"
28+
const assign_user = "kwilcox"
29+
30+
const fs = require("fs")
31+
32+
const release = await github.repos.getLatestRelease({
33+
owner: "BobSimons",
34+
repo: "erddap"
35+
})
36+
const tag = release.data.tag_name
37+
38+
const dockerfile = fs.readFileSync(`${process.env.GITHUB_WORKSPACE}/Dockerfile`, "utf-8")
39+
const lines = dockerfile.split("\n")
40+
const docker_version_line = lines.find(line => line.includes("ERDDAP_VERSION"))
41+
const docker_version = `v${docker_version_line.split(" ")[2]}`
42+
43+
if (tag === docker_version) {
44+
console.log(`Latest Docker version (${docker_version}) matches the latest available BobSimmons/erddap release`)
45+
46+
return
47+
}
48+
49+
console.log(`Latest Docker version (${docker_version}) does not match the latest available BobSimmons/erddap release (${tag})`)
50+
51+
const query = `query($owner: String!, $name: String!) {
52+
repository(owner: $owner, name: $name) {
53+
issues(first: 5, states: OPEN) {
54+
nodes {
55+
id
56+
title
57+
}
58+
}
59+
}
60+
}`
61+
62+
const issue_label = "erddapversion"
63+
const issue_title = `Update ERDDAP to ${tag}`
64+
65+
const variables = {
66+
owner: repo_owner,
67+
name: repo_name,
68+
label: issue_label
69+
}
70+
const result = await github.graphql(query, variables)
71+
const issues = result.repository.issues.nodes
72+
const issue_for_version = issues.find(issue => issue.title.includes(issue_title))
73+
74+
if (issue_for_version !== undefined) {
75+
console.log(`There is already an issue created for the latest version of ERDDAP`)
76+
return
77+
}
78+
79+
console.log("Creating a new issue to update the ERDDAP version")
80+
81+
const issue_body = `
82+
ERDDAP has been updated to ${tag}!
83+
84+
@${assign_user} Please update and test the version in the Dockerfile.
85+
`
86+
87+
const issue = await github.issues.create({
88+
owner: repo_owner,
89+
repo: repo_name,
90+
title: issue_title,
91+
labels: [issue_label],
92+
body: issue_body,
93+
assignees: [
94+
assign_user
95+
]
96+
})
97+
98+
console.log(`New issue created at ${issue.data.html_url}`)

0 commit comments

Comments
 (0)