Skip to content

Commit 86f371f

Browse files
committed
Allow users to specify a context; load the proper build cache
1 parent d62d38d commit 86f371f

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

action.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,33 @@ inputs:
2222
registry_pass:
2323
description: 'Password of the registry'
2424
required: true
25+
context:
26+
description: 'Path to container files, including Dockerfile'
27+
required: false
28+
default: '.'
2529

2630
runs:
2731
using: "composite"
2832
steps:
2933
- uses: actions/checkout@v2
3034

35+
- id: generate-image-name
36+
shell: bash
37+
run: |
38+
if [[ ${{ inputs.context }} == "." ]] || \
39+
[[ ${{ inputs.context }} == "./" ]]; then
40+
# Try to guess the image name from our docker repo naming conventions
41+
# E.g., opensciencegrid/docker-frontier-squid
42+
IMAGE_NAME=${GITHUB_REPOSITORY/opensciencegrid\/docker-//}
43+
elif [[ -d ${{ inputs.context }} ]]; then
44+
# Assume that the containing dir is the image name
45+
IMAGE_NAME=$(basename ${{ inputs.context }})
46+
else
47+
echo "${{ inputs.context }} is not a directory"
48+
exit 1
49+
fi
50+
echo "::set-output name=image::$IMAGE_NAME"
51+
3152
- name: Generate tag list
3253
id: generate-tag-list
3354
env:
@@ -52,7 +73,7 @@ runs:
5273
uses: actions/cache@v2
5374
with:
5475
path: /tmp/.buildx-cache
55-
key: ${{ inputs.osg_series}}-${{ inputs.repo }}-buildx-${{ github.sha }}-${{ github.run_id }}
76+
key: ${{ steps.generate-image-name.outputs.image }}_${{ inputs.osg_series}}_${{ inputs.repo }}_buildx_${{ github.sha }}_${{ github.run_id }}
5677

5778
- name: Set up Docker Buildx
5879
uses: docker/setup-buildx-action@v1
@@ -68,6 +89,7 @@ runs:
6889
uses: docker/[email protected]
6990
with:
7091
push: true
92+
context: ${{ inputs.context }}
7193
build-args: |
7294
BASE_YUM_REPO=${{ inputs.repo }}
7395
BASE_OSG_SERIES=${{ inputs.osg_series }}

0 commit comments

Comments
 (0)