Skip to content

Commit 676d784

Browse files
committed
Initial commit
0 parents  commit 676d784

22 files changed

+12828
-0
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.eslintrc.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es2022": true,
5+
"jest/globals": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:jest/recommended",
10+
"plugin:prettier/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaVersion": "latest"
14+
},
15+
"plugins": [
16+
"jest",
17+
"prettier"
18+
]
19+
}

.github/workflows/ci.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened ]
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test-action:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Generate hash
18+
id: generate
19+
uses: ./
20+
with:
21+
build_context: ./test/
22+
- name: Check
23+
run: |
24+
echo "${{ toJson(steps.generate) }}"
25+
# Expected hash generated from command below
26+
# {\
27+
# git ls-tree -r --format='%(objectname)' HEAD \
28+
# test/a/b \
29+
# test/context/file \
30+
# test/filename \
31+
# test/.dockerignore \
32+
# test/Dockerfile\
33+
# ; \
34+
# printf "test/a/b\ntest/context/file\ntest/filename\ntest/.dockerignore\ntest/Dockerfile" | \
35+
# git hash-object --stdin\
36+
# ;\
37+
# } | git hash-object --stdin
38+
if [ "${{ steps.generate.hash }}" != "6d09883618bd309806be67847737b1a5a4aa1f40"]; then
39+
echo "::error::Invalid hash value"
40+
exit 1
41+
fi
42+
43+
test:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v3
47+
- uses: actions/setup-node@v3
48+
with:
49+
node-version: '18.x'
50+
- run: npm ci
51+
- run: npm run lint
52+
- run: npm test
53+
# TODO: Coverage

.github/workflows/validate.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Validate
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened ]
6+
branches:
7+
- main
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
validate:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: '18.x'
20+
- name: Validate build
21+
shell: bash
22+
run: |
23+
set -e
24+
git add -A
25+
npm run package
26+
if [ -n "$(git status --porcelain -- dist)" ]; then
27+
echo "::error::Build result differs. Run 'npm run package' then commit and push any changes"
28+
git status --porcelain -- dist
29+
exit 1
30+
fi

.gitignore

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
93+
# Gatsby files
94+
.cache/
95+
# Comment in the public line in if your project uses Gatsby and not Next.js
96+
# https://nextjs.org/blog/next-9-1#public-directory-support
97+
# public
98+
99+
# vuepress build output
100+
.vuepress/dist
101+
102+
# vuepress v2.x temp and cache directory
103+
.temp
104+
.cache
105+
106+
# Docusaurus cache and generated files
107+
.docusaurus
108+
109+
# Serverless directories
110+
.serverless/
111+
112+
# FuseBox cache
113+
.fusebox/
114+
115+
# DynamoDB Local files
116+
.dynamodb/
117+
118+
# TernJS port file
119+
.tern-port
120+
121+
# Stores VSCode versions used for testing VSCode extensions
122+
.vscode-test
123+
124+
# yarn v2
125+
.yarn/cache
126+
.yarn/unplugged
127+
.yarn/build-state.yml
128+
.yarn/install-state.gz
129+
.pnp.*

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 5 Monkeys
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Docker image context hash
2+
3+
![](https://github.com/5monkeys/docker-image-context-hash-action/workflows/CI/badge.svg)
4+
5+
6+
## Example usage
7+
8+
```yaml
9+
on:
10+
pull_request:
11+
```
12+
13+
## Development
14+
15+
- Install deps: `npm ci`
16+
- Run tests: `npm run test`
17+
- Run lint: `npm run lint`
18+
- Pcakage application: `npm run package`. Remember to run this before committing anything.

action.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "docker-image-context-hash"
2+
description: "Generates a hash for a docker image context"
3+
author: '5monkeys'
4+
branding:
5+
icon: 'layers'
6+
color: 'yellow'
7+
8+
inputs:
9+
build_context:
10+
description: "What path to give to docker as build context"
11+
default: '.'
12+
extra_tree_objects:
13+
description: "Tree objects (files) to be included in addition to the docker image context"
14+
required: false
15+
extra_values:
16+
description: "Additional values that should be included when generating the hash"
17+
required: false
18+
19+
outputs:
20+
hash:
21+
description: 'An object ID of a docker image context'
22+
23+
runs:
24+
using: 'node18'
25+
main: 'dist/index.js'

0 commit comments

Comments
 (0)