-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic generation and pushing of docker images. If a branch is being pushed, then docker image pcesapps-dev is updated with the latest and timestamp tags. If a tag is being pushed, then docker image pcesapps-beta is updated with the latest, timestamp, and git tag tags. If the docker-build.sh script is invoked by hand, with no arguments, then pcseapps-test is updated with a timestamp tag.
- Loading branch information
1 parent
1d73d3e
commit 509e20d
Showing
3 changed files
with
92 additions
and
19 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,36 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: [ "*" ] | ||
tags: [ "v*" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: update image vars | ||
run: | | ||
if [ "$GITHUB_REF_TYPE" = "tag" ] | ||
then | ||
echo IMAGE_TYPE=beta | ||
echo IMAGE_TAG=$GITHUB_REF_NAME | ||
else | ||
echo IMAGE_TYPE=dev | ||
echo IMAGE_TAG= | ||
fi >> $GITHUB_ENV | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/checkout@v4 | ||
- name: Build the Docker image | ||
run: cd beta && ./docker-build.sh $IMAGE_TYPE $IMAGE_TAG |
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 |
---|---|---|
@@ -1,9 +1,46 @@ | ||
#!/bin/sh -ex | ||
#!/bin/bash -e | ||
# Copyright 2024 The Board of Trustees of the University of Illinois | ||
|
||
TAG=ghcr.io/iti/pcesapps-beta:v0.1.1 | ||
TAG2=ghcr.io/iti/pcesapps-beta:latest | ||
cp ../go.mod ../go.sum . | ||
docker build --no-cache -t $TAG -t $TAG2 . | ||
docker push $TAG | ||
docker push $TAG2 | ||
# Usage: docker-build.sh [suffix [version ...]] | ||
# Builds a docker image | ||
# and pushes it with the tags | ||
# ghcr.io/iti/pocesapps-$suffix:$version1 | ||
# ghcr.io/iti/pocesapps-$suffix:$version2 | ||
# ... | ||
# The default value of "$suffix" is test. | ||
# Additionally, versions of $(date) and "latest" | ||
# are always created | ||
# | ||
# To test your code from the command line: | ||
# ./docker-build.sh | ||
# ./docker-run.sh | ||
# That creates ghcr.io.iti/pcesapps-test:latest | ||
# | ||
# Whenever you git push a branch, the ci/cd runs: | ||
# ./docker-build.sh dev | ||
# This creates ghcr.io/iti/pcesappos-dev:latest | ||
# | ||
# Whever your git push a tag, the ci/cd runs: | ||
# ./docker-build.shy beta $tag | ||
# This creates ghcr.io/iti/pcesapps-beta:$tag | ||
|
||
#pfx="ghcr.io/illinoisadams/doc-test" | ||
pfx="ghcr.io/iti/pcesapps" | ||
|
||
now=$(date -u +%F-%H-%M-%S) | ||
if "$1" = "" | ||
then | ||
image="$pfx-test" | ||
latest= | ||
else | ||
image="$pfx-$1" | ||
shift | ||
latest=( "latest" "$@" ) | ||
fi | ||
|
||
docker build --no-cache -t "$image:$now" . | ||
docker push "$image:$now" | ||
for v in "${latest[@]}" ; do | ||
docker tag "$image:$now" "$image:$v" | ||
docker push "$image:$v" | ||
done |