-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a build argument for specifying the Packer version
Set default version to `latest` Using the Docker Action build argument workaround suggested from: https://github.community/t/feature-request-build-args-support-in-docker-container-actions/16846/6
- Loading branch information
Showing
6 changed files
with
54 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
FROM hashicorp/packer:1.6.4 | ||
FROM alpine:latest | ||
|
||
LABEL "com.github.actions.name" = "Packer AMI Builder" | ||
LABEL "com.github.actions.description" = "Use GitHub Action to execute Packer AMI build" | ||
LABEL "com.github.actions.color"="blue" | ||
LABEL "com.github.actions.icon"="anchor" | ||
|
||
COPY docker-action /docker-action | ||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
|
||
RUN apk add --update --no-cache docker | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ARG packer_version | ||
FROM hashicorp/packer:${packer_version} | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
cd "${INPUT_WORKDIR:-.}" | ||
|
||
# Show Packer version | ||
packer version | ||
|
||
# Run packer with the given arguments | ||
packer ${INPUT_PACKERARGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
#!/bin/bash | ||
set -ex | ||
#!/bin/sh | ||
|
||
cd "${INPUT_WORKDIR:-.}" | ||
PACKER_VERSION=$1 | ||
|
||
# Run packer with the given arguments | ||
packer ${INPUT_PACKERARGS} | ||
# The repo source code is cloned to $RUNNER_WORKSPACE/$REPO_NAME | ||
# Setup the workspace path to that for easier access later | ||
REPO_NAME=$(basename $RUNNER_WORKSPACE) | ||
WS_PATH=$RUNNER_WORKSPACE/$REPO_NAME | ||
|
||
cd /docker-action | ||
|
||
echo "Creating a docker image with Packer version: $PACKER_VERSION" | ||
docker build -t docker-action --build-arg packer_version="$PACKER_VERSION" . | ||
|
||
echo "Run Docker Action container" | ||
docker run -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_DEFAULT_REGION \ | ||
-e INPUT_PACKERARGS -e INPUT_PACKERVERSION -e INPUT_WORKDIR \ | ||
-v $WS_PATH:$GITHUB_WORKSPACE \ | ||
--workdir $GITHUB_WORKSPACE docker-action |