Skip to content

Commit cd5342c

Browse files
author
e
committed
Use node 16
1 parent cc3f382 commit cd5342c

File tree

8 files changed

+613
-429
lines changed

8 files changed

+613
-429
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- uses: actions/setup-node@v1
19+
- uses: actions/setup-node@v3
2020
with:
21-
node-version: 12.x
21+
node-version: 16.x
2222

23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
2424

2525
- name: Output info
2626
id: info
@@ -31,7 +31,7 @@ jobs:
3131
fi
3232
echo '::set-output name=commit_message::[auto]'
3333
34-
- uses: satackey/push-prebuilt-action@v0.2.0-beta3
34+
- uses: jpribyl/push-prebuilt-action@v0.2.3
3535
with:
3636
commit-message: ${{ steps.info.outputs.commit_message }}
3737
push-branch: '{branch}-release'
@@ -69,12 +69,12 @@ jobs:
6969
}, {
7070
inspect_image: 'nothing',
7171
os: 'ubuntu-latest',
72-
prepare_command: 'docker tag node:12 nothing',
72+
prepare_command: 'docker tag node:16 nothing',
7373
build_command: ':',
7474
}, {
7575
inspect_image: 'nothing',
7676
os: 'windows-latest',
77-
prepare_command: 'docker tag mcr.microsoft.com/windows/nanoserver:1809 nothing',
77+
prepare_command: 'docker tag mcr.microsoft.com/windows/nanoserver:1803-amd64 nothing',
7878
build_command: ':',
7979
}, {
8080
branch: process.env.GITHUB_REF.replace('refs/heads/', '')
@@ -99,7 +99,7 @@ jobs:
9999
runs-on: ${{ matrix.os }}
100100

101101
steps:
102-
- uses: actions/checkout@v2
102+
- uses: actions/checkout@v3
103103

104104
- run: ${{ matrix.prepare_command }}
105105

@@ -108,9 +108,8 @@ jobs:
108108
with:
109109
name: built
110110
path: action-dlc
111-
112111
- uses: ./action-dlc
113-
name: Run satackey/action-docker-layer-caching@${{ matrix.branch }}
112+
name: Run jpribyl/action-docker-layer-caching@${{ matrix.branch }}
114113
with:
115114
key: docker-layer-caching-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
116115

@@ -123,7 +122,7 @@ jobs:
123122
runs-on: ${{ matrix.os }}
124123

125124
steps:
126-
- uses: actions/checkout@v2
125+
- uses: actions/checkout@v3
127126

128127
- run: ${{ matrix.prepare_command }}
129128

@@ -139,7 +138,7 @@ jobs:
139138
path: action-dlc
140139

141140
- uses: ./action-dlc
142-
name: Run satackey/action-docker-layer-caching@${{ matrix.branch }}
141+
name: Run jpribyl/action-docker-layer-caching@${{ matrix.branch }}
143142
with:
144143
key: never-restored-docker-layer-caching-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
145144
restore-keys: docker-layer-caching-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-

.github/workflows/test_readme.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777

7878
- run: ${{ matrix.prepare_command }}
7979

80-
- uses: satackey/action-docker-layer-caching@master-release
80+
- uses: jpribyl/action-docker-layer-caching@master-release
8181
with:
8282
key: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
8383
restore-keys: ''
@@ -95,7 +95,7 @@ jobs:
9595

9696
- run: ${{ matrix.prepare_command }}
9797

98-
- uses: satackey/action-docker-layer-caching@master-release
98+
- uses: jpribyl/action-docker-layer-caching@master-release
9999
with:
100100
key: never-restored-docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-{hash}
101101
restore-keys: docker-layer-caching-${{ github.workflow }}-${{ matrix.os }}-${{ matrix.inspect_image }}-sha:${{ github.sha }}-
@@ -105,7 +105,7 @@ jobs:
105105
run: docker inspect ${{ matrix.inspect_image }}
106106

107107
- name: Get cached image ID
108-
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
108+
run: echo id=$(docker image ls -q ${{ matrix.inspect_image }}) >> $GITHUB_OUTPUT
109109
id: cached
110110

111111
- run: ${{ matrix.build_command }}
@@ -114,7 +114,7 @@ jobs:
114114
run: docker inspect ${{ matrix.inspect_image }}
115115

116116
- name: Show built image ID
117-
run: echo ::set-output name=id::$(docker image ls -q ${{ matrix.inspect_image }})
117+
run: echo id=$(docker image ls -q ${{ matrix.inspect_image }}) >> $GITHUB_OUTPUT
118118
id: latest
119119

120120
- name: Compare cached ID and after build ID

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Layer Caching
1+
name: Docker Layer Caching2
22
description: Cache images created between main run and post run
33

44
branding:
@@ -24,6 +24,6 @@ inputs:
2424
default: 'false'
2525

2626
runs:
27-
using: node12
27+
using: node16
2828
main: main.ts
2929
post: post.ts

main.ts

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,59 @@
1-
import * as core from '@actions/core'
2-
import * as exec from 'actions-exec-listener'
3-
import { LayerCache } from './src/LayerCache'
4-
import { ImageDetector } from './src/ImageDetector'
1+
import * as core from "@actions/core";
2+
import * as exec from "actions-exec-listener";
3+
import { LayerCache } from "./src/LayerCache";
4+
import { ImageDetector } from "./src/ImageDetector";
55

66
const main = async () => {
7-
const primaryKey = core.getInput(`key`, { required: true })
8-
const restoreKeys = core.getInput(`restore-keys`, { required: false }).split(`\n`).filter(key => key !== ``)
7+
console.log("1");
8+
const primaryKey = core.getInput(`key`, { required: true });
9+
console.log("2");
10+
const restoreKeys = core
11+
.getInput(`restore-keys`, { required: false })
12+
.split(`\n`)
13+
.filter((key) => key !== ``);
14+
console.log("3");
915

10-
const imageDetector = new ImageDetector()
16+
const imageDetector = new ImageDetector();
1117

12-
const alreadyExistingImages = await imageDetector.getExistingImages()
13-
core.saveState(`already-existing-images`, JSON.stringify(alreadyExistingImages))
18+
console.log("4");
19+
const alreadyExistingImages = await imageDetector.getExistingImages();
20+
console.log("5", alreadyExistingImages);
21+
core.saveState(
22+
`already-existing-images`,
23+
JSON.stringify(alreadyExistingImages)
24+
);
25+
console.log("6");
1426

15-
const layerCache = new LayerCache([])
16-
layerCache.concurrency = parseInt(core.getInput(`concurrency`, { required: true }), 10)
17-
const restoredKey = await layerCache.restore(primaryKey, restoreKeys)
18-
await layerCache.cleanUp()
27+
const layerCache = new LayerCache([]);
28+
console.log("7");
29+
layerCache.concurrency = parseInt(
30+
core.getInput(`concurrency`, { required: true }),
31+
10
32+
);
33+
console.log("8");
34+
const restoredKey = await layerCache.restore(primaryKey, restoreKeys);
35+
console.log("9", restoredKey);
36+
await layerCache.cleanUp();
37+
console.log("10");
1938

20-
core.saveState(`restored-key`, JSON.stringify(restoredKey !== undefined ? restoredKey : ''))
21-
core.saveState(`restored-images`, JSON.stringify(await imageDetector.getImagesShouldSave(alreadyExistingImages)))
22-
}
39+
core.saveState(
40+
`restored-key`,
41+
JSON.stringify(restoredKey !== undefined ? restoredKey : "")
42+
);
43+
console.log("11");
44+
core.saveState(
45+
`restored-images`,
46+
JSON.stringify(
47+
await imageDetector.getImagesShouldSave(alreadyExistingImages)
48+
)
49+
);
50+
console.log("12");
51+
};
2352

24-
main().catch(e => {
25-
console.error(e)
26-
core.setFailed(e)
53+
main().catch((e) => {
54+
console.error(e);
55+
core.setFailed(e);
2756

28-
core.saveState(`restored-key`, JSON.stringify(``))
29-
core.saveState(`restored-images`, JSON.stringify([]))
30-
})
57+
core.saveState(`restored-key`, JSON.stringify(``));
58+
core.saveState(`restored-images`, JSON.stringify([]));
59+
});

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"native-promise-pool": "^3.16.0",
1616
"recursive-readdir": "^2.2.2",
1717
"string-format": "^2.0.0",
18-
"typescript-is": "^0.17.1"
18+
"typescript-is": "^0.19.0"
1919
},
2020
"devDependencies": {
2121
"@types/node": "^14.14.14",
2222
"@types/string-format": "^2.0.0",
23-
"@zeit/ncc": "^0.22.3",
23+
"@vercel/ncc": "^0.34.0",
2424
"ts-node": "^9.1.1",
25-
"ttypescript": "^1.5.12",
26-
"typescript": "^4.2.3"
25+
"ttypescript": "^1.5.13",
26+
"typescript": ">=4.1.5 <4.7.2"
2727
}
2828
}

src/ImageDetector.ts

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
1-
import * as exec from 'actions-exec-listener'
2-
import * as core from '@actions/core'
1+
import * as exec from "actions-exec-listener";
2+
import * as core from "@actions/core";
33

44
export class ImageDetector {
55
async getExistingImages(): Promise<string[]> {
6-
const existingSet = new Set<string>([])
7-
const ids = (await exec.exec(`docker image ls -q`, [], { silent: true, listeners: { stderr: console.warn }})).stdoutStr.split(`\n`).filter(id => id !== ``)
8-
const repotags = (await exec.exec(`docker`, `image ls --format {{.Repository}}:{{.Tag}} --filter dangling=false`.split(' '), { silent: true, listeners: { stderr: console.warn }})).stdoutStr.split(`\n`).filter(id => id !== ``);
6+
const existingSet = new Set<string>([]);
7+
const ids = (
8+
await exec.exec(`docker image ls -q`, [], {
9+
silent: true,
10+
listeners: { stderr: console.warn },
11+
})
12+
).stdoutStr
13+
.split(`\n`)
14+
.filter((id) => id !== ``);
15+
const repotags = (
16+
await exec.exec(
17+
`docker`,
18+
`image ls --format {{.Repository}}:{{.Tag}} --filter dangling=false`.split(
19+
" "
20+
),
21+
{ silent: true, listeners: { stderr: console.warn } }
22+
)
23+
).stdoutStr
24+
.split(`\n`)
25+
.filter((id) => id !== ``);
926
core.debug(JSON.stringify({ log: "getExistingImages", ids, repotags }));
10-
([...ids, ...repotags]).forEach(image => existingSet.add(image))
11-
core.debug(JSON.stringify({ existingSet }))
12-
return Array.from(existingSet)
27+
[...ids, ...repotags].forEach((image) => existingSet.add(image));
28+
core.debug(JSON.stringify({ existingSet }));
29+
return Array.from(existingSet);
1330
}
1431

15-
async getImagesShouldSave(alreadRegisteredImages: string[]): Promise<string[]> {
16-
const resultSet = new Set(await this.getExistingImages())
17-
alreadRegisteredImages.forEach(image => resultSet.delete(image))
18-
return Array.from(resultSet)
32+
async getImagesShouldSave(
33+
alreadRegisteredImages: string[]
34+
): Promise<string[]> {
35+
const resultSet = new Set(await this.getExistingImages());
36+
alreadRegisteredImages.forEach((image) => resultSet.delete(image));
37+
return Array.from(resultSet);
1938
}
2039
}

0 commit comments

Comments
 (0)