Skip to content

Commit 9dc7a10

Browse files
committed
chore: upgrade to latest workflows
1 parent 7df5063 commit 9dc7a10

2 files changed

Lines changed: 70 additions & 64 deletions

File tree

.github/workflows/docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,9 @@ jobs:
357357
const file = readFileSync(path).toString();
358358
switch(true){
359359
case /11notes\/go\:\$\{APP_GO_VERSION\}/ig.test(file): core.exportVariable('WORKFLOW_IMAGE_DEPENDENCY', 'go'); break;
360+
case /11notes\/python\:\$\{APP_PYTHON_VERSION\}/ig.test(file): core.exportVariable('WORKFLOW_IMAGE_DEPENDENCY', 'python'); break;
361+
case /11notes\/php\:\$\{APP_PHP_VERSION\}/ig.test(file): core.exportVariable('WORKFLOW_IMAGE_DEPENDENCY', 'php'); break;
362+
case /11notes\/php-fpm\:\$\{APP_PHP_VERSION\}/ig.test(file): core.exportVariable('WORKFLOW_IMAGE_DEPENDENCY', 'php'); break;
360363
}
361364
}catch(e){
362365
throw new Error(`could not open ./${dockerfile}: ${e}`);

.github/workflows/org.update.yml

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
6262
// defaults
6363
const json = `${{ toJSON(github.event.inputs) }}`;
64-
const job = {inputs:{}, json:{}};
64+
const job = {inputs:{}, json:{}, fail:false};
6565
6666
// check if inputs is valid base64 encoded json
6767
try{
@@ -75,7 +75,8 @@ jobs:
7575
}else if(!job.inputs?.tag){
7676
core.setFailed(`input does not contain valid git tag: ${inspect(job.inputs, {showHidden:false, depth:null, colors:true})}`);
7777
}else if(job.inputs.version == 'null' || null === job.inputs.version){
78-
core.setFailed(`input version is null: ${inspect(job.inputs, {showHidden:false, depth:null, colors:true})}`);
78+
core.warning(`input version is null: ${inspect(job.inputs, {showHidden:false, depth:null, colors:true})}`);
79+
job.fail = true;
7980
}
8081
}catch(e){
8182
core.setFailed(`could not parse github.event.inputs.etc: ${n.etc} (${Buffer.from(n.etc, 'base64').toString('ascii')})`);
@@ -86,77 +87,79 @@ jobs:
8687
core.setFailed(`could not parse github.event.inputs: ${json}`);
8788
}
8889
89-
// check if .json exists
90-
try{
91-
const path = resolve('.json');
92-
if(existsSync(path)){
93-
try{
94-
job.json = JSON.parse(readFileSync(path).toString());
95-
}catch(e){
96-
throw new Error('could not parse .json');
90+
if(!job.fail){
91+
// check if .json exists
92+
try{
93+
const path = resolve('.json');
94+
if(existsSync(path)){
95+
try{
96+
job.json = JSON.parse(readFileSync(path).toString());
97+
}catch(e){
98+
throw new Error('could not parse .json');
99+
}
100+
}else{
101+
throw new Error('.json does not exist!');
97102
}
98-
}else{
99-
throw new Error('.json does not exist!');
103+
}catch(e){
104+
core.setFailed(e);
100105
}
101-
}catch(e){
102-
core.setFailed(e);
103-
}
104106
105-
// semver
106-
const latest = semverExceptions(semver.valid(semver.coerce(job.inputs.version)));
107-
const current = semverExceptions(semver.valid(semver.coerce(job.json.semver.version)));
108-
const tag = semver.valid(semver.coerce(job.inputs.tag));
109-
const checks = {latestTagExists:false};
107+
// semver
108+
const latest = semverExceptions(semver.valid(semver.coerce(job.inputs.version)));
109+
const current = semverExceptions(semver.valid(semver.coerce(job.json.semver.version)));
110+
const tag = semver.valid(semver.coerce(job.inputs.tag));
111+
const checks = {latestTagExists:false};
110112
111-
try{
112-
const tag = await fetch(`https://hub.docker.com/v2/repositories/${job.json.image}/tags/${latest}`);
113-
if(tag.status === 200){
114-
checks.latestTagExists = true;
115-
}
116-
}catch(e){
117-
core.warning(e);
118-
}
119-
120-
// compare
121-
if(latest && latest !== current && !checks.latestTagExists){
122-
core.info(`new ${semver.diff(current, latest)} release found (${latest}), updating ...`)
123-
job.json.semver.version = latest;
124-
125-
// check if app has additional parameters
126-
const build = {};
127-
if(job.inputs?.build && typeof(job.inputs.build) === 'string'){
128-
build.args = {
129-
version_build:job.inputs.build,
130-
};
131-
job.json.build.args.version_build = job.inputs.build;
132-
}else if(job.inputs?.build?.args){
133-
build.args = job.inputs.build.args;
134-
job.json.build.args.version_build = job.inputs.build.args;
113+
try{
114+
const tag = await fetch(`https://hub.docker.com/v2/repositories/${job.json.image}/tags/${latest}`);
115+
if(tag.status === 200){
116+
checks.latestTagExists = true;
117+
}
118+
}catch(e){
119+
core.warning(e);
135120
}
136121
137-
// update .json
138-
try{
139-
writeFileSync(resolve('.json'), JSON.stringify(job.json, null, 2));
140-
141-
// export variables
142-
core.exportVariable('WORKFLOW_UPDATE', true);
143-
core.exportVariable('WORKFLOW_UPDATE_BASE64JSON', Buffer.from(JSON.stringify({build:build})).toString('base64'));
144-
if(job.inputs?.unraid){
145-
core.exportVariable('WORKFLOW_UPDATE_UNRAID', 'true');
146-
core.exportVariable('WORKFLOW_UPDATE_UNRAID_BASE64JSON', Buffer.from(JSON.stringify({semversuffix:"unraid", uid:99, gid:100, build:build})).toString('base64'));
122+
// compare
123+
if(latest && latest !== current && !checks.latestTagExists){
124+
core.info(`new ${semver.diff(current, latest)} release found (${latest}), updating ...`)
125+
job.json.semver.version = latest;
126+
127+
// check if app has additional parameters
128+
const build = {};
129+
if(job.inputs?.build && typeof(job.inputs.build) === 'string'){
130+
build.args = {
131+
version_build:job.inputs.build,
132+
};
133+
job.json.build.args.version_build = job.inputs.build;
134+
}else if(job.inputs?.build?.args){
135+
build.args = job.inputs.build.args;
136+
job.json.build.args.version_build = job.inputs.build.args;
147137
}
148-
if(job.inputs?.nobody){
149-
core.exportVariable('WORKFLOW_UPDATE_NOBODY', 'true');
150-
core.exportVariable('WORKFLOW_UPDATE_NOBODY_BASE64JSON', Buffer.from(JSON.stringify({semversuffix:"nobody", uid:65534, gid:65534, build:build})).toString('base64'));
138+
139+
// update .json
140+
try{
141+
writeFileSync(resolve('.json'), JSON.stringify(job.json, null, 2));
142+
143+
// export variables
144+
core.exportVariable('WORKFLOW_UPDATE', true);
145+
core.exportVariable('WORKFLOW_UPDATE_BASE64JSON', Buffer.from(JSON.stringify({build:build})).toString('base64'));
146+
if(job.inputs?.unraid){
147+
core.exportVariable('WORKFLOW_UPDATE_UNRAID', 'true');
148+
core.exportVariable('WORKFLOW_UPDATE_UNRAID_BASE64JSON', Buffer.from(JSON.stringify({semversuffix:"unraid", uid:99, gid:100, build:build})).toString('base64'));
149+
}
150+
if(job.inputs?.nobody){
151+
core.exportVariable('WORKFLOW_UPDATE_NOBODY', 'true');
152+
core.exportVariable('WORKFLOW_UPDATE_NOBODY_BASE64JSON', Buffer.from(JSON.stringify({semversuffix:"nobody", uid:65534, gid:65534, build:build})).toString('base64'));
153+
}
154+
core.exportVariable('LATEST_TAG', semver.inc(tag, semver.diff(current, latest)));
155+
core.exportVariable('LATEST_VERSION', latest);
156+
if(job.inputs?.build) core.exportVariable('LATEST_BUILD', job.inputs.build);
157+
}catch(e){
158+
core.setFailed(e);
151159
}
152-
core.exportVariable('LATEST_TAG', semver.inc(tag, semver.diff(current, latest)));
153-
core.exportVariable('LATEST_VERSION', latest);
154-
if(job.inputs?.build) core.exportVariable('LATEST_BUILD', job.inputs.build);
155-
}catch(e){
156-
core.setFailed(e);
160+
}else{
161+
core.info('no update required')
157162
}
158-
}else{
159-
core.info('no update required')
160163
}
161164
162165
core.info(inspect(job, {showHidden:false, depth:null, colors:true}));

0 commit comments

Comments
 (0)