forked from rtCamp/action-slack-notify
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from BlueWhaleKo/master
feature: support linux/arm64 architecture
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build-and-push: | ||
./scripts/build-and-push.sh ghcr.io/rtcamp/action-slack-notify:v2.2.0 |
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,60 @@ | ||
#!/bin/bash | ||
|
||
IMAGE=$1 | ||
BUILDX_INSTANCE="action-slack-notify-builder" | ||
PLATFORMS="linux/arm64,linux/amd64" | ||
|
||
function print_usage { | ||
echo "$0 <Image>" | ||
} | ||
|
||
function validate_command_line_args { | ||
if [[ -z "$IMAGE" ]]; then | ||
echo "Image is not supplied" | ||
print_usage | ||
exit 1 | ||
fi | ||
|
||
echo "==================================" | ||
echo "Arguments" | ||
echo "Image: $IMAGE" | ||
echo "==================================" | ||
} | ||
|
||
function validate_docker_installed { | ||
if ! [[ $(command -v docker) ]]; then | ||
echo "Docker is not installed. Install docker first" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function setup_buildx_platforms { | ||
echo "Install buildx platforms" | ||
docker run --privileged --rm tonistiigi/binfmt --install all > /dev/null | ||
} | ||
|
||
function setup_buildx_instance { | ||
echo "Check buildx instance '$BUILDX_INSTANCE' is set" | ||
|
||
if [[ $(docker buildx ls | grep $BUILDX_INSTANCE | grep docker-container | wc -l ) -eq 0 ]]; then | ||
echo "Create buildx instance '$BUILDX_INSTANCE'" | ||
docker buildx create --name=$BUILDX_INSTANCE --driver=docker-container | ||
echo "Successfully created and converted to buildx instance '$BUILDX_INSTANCE'" | ||
else | ||
echo "Buildx instance $BUILDX_INSTANCE is ready. Skip..." | ||
fi | ||
} | ||
|
||
function build_and_push_images { | ||
echo "Build and push docker images" | ||
docker buildx build --builder=$BUILDX_INSTANCE --platform=$PLATFORMS --push -t $IMAGE . | ||
} | ||
|
||
|
||
validate_command_line_args | ||
validate_docker_installed | ||
|
||
setup_buildx_platforms | ||
setup_buildx_instance | ||
|
||
build_and_push_images |