Skip to content

Commit

Permalink
Tweak variables, and caching in docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcooper committed Sep 20, 2024
1 parent 246796b commit 029c52f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
18 changes: 15 additions & 3 deletions .github/actions/docker-build-push/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
description: Do not use cache when building
required: false
default: 'false'
cache-tag:
description: Tag to use for cache when building (default '<container>-<tag>')
required: false
default: ''
build-args:
description: List of build-time variables
required: false
Expand All @@ -36,9 +40,17 @@ runs:
shell: bash
run: |
USERNAME="$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')"
echo "CACHE_TAG=ghcr.io/${USERNAME}/tomato-build-cache:${{ inputs.container }}-${{ inputs.tag }}" >> "$GITHUB_ENV"
echo "REPO=ghcr.io/${USERNAME}/tomato-${{ inputs.container }}" >> "$GITHUB_ENV"
echo "USERNAME=${USERNAME}" >> "$GITHUB_ENV"
CACHE_CONTAINER=ghcr.io/${USERNAME}/tomato-build-cache
if [ "${{ inputs.no-cache }}" = 'true' ]; then
CACHE_TAG=''
elif [ "${{ inputs.cache-tag }}" ]; then
CACHE_TAG="${CACHE_CONTAINER}:${{ inputs.cache-tag }}"
else
CACHE_TAG="${CACHE_CONTAINER}:${{ inputs.container }}-${{ inputs.tag }}"
fi
echo "CACHE_TAG=${CACHE_TAG}" | tee -a "${GITHUB_ENV}"
echo "REPO=ghcr.io/${USERNAME}/tomato-${{ inputs.container }}" | tee -a "${GITHUB_ENV}"
echo "USERNAME=${USERNAME}" | tee -a "${GITHUB_ENV}"
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ runs:
PROTOCOL="$(jq -r .protocol_version server/constants.json)"
echo 'Setting Tomato versions'
echo "version=${VERSION}" | tee -a "$GITHUB_OUTPUT"
echo "protocol=${PROTOCOL}" | tee -a "$GITHUB_OUTPUT"
echo "version-short=${VERSION_SHORT}" | tee -a "$GITHUB_OUTPUT"
echo "version=${VERSION}" | tee -a "${GITHUB_OUTPUT}"
echo "protocol=${PROTOCOL}" | tee -a "${GITHUB_OUTPUT}"
echo "version-short=${VERSION_SHORT}" | tee -a "${GITHUB_OUTPUT}"
4 changes: 2 additions & 2 deletions .github/workflows/build-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ jobs:
name: Set variables
shell: bash
run: |
echo "CLIENT_FILENAME=tomato-client-${{ env.CLIENT_VERSION }}-${{ matrix.filename_suffix }}" >> "$GITHUB_ENV"
echo "CLIENT_FILENAME=tomato-client-${{ env.CLIENT_VERSION }}-${{ matrix.filename_suffix }}" | tee -a "${GITHUB_ENV}"
if [ "${{ github.ref_type }}" != 'tag' -a "${{ github.ref_name}}" != main ]; then
echo "EXTRA_BUILD_INFO=Branch: ${{ github.ref_name}}" >> "$GITHUB_ENV"
echo "EXTRA_BUILD_INFO=Branch: ${{ github.ref_name}}" | tee -a "${GITHUB_ENV}"
fi
-
name: Setup Node v${{ env.NODE_VERSION }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-deploy-on-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
if [ "$DATE" -ge "$BEFORE_DATE" -a "$DATE" -le "$AFTER_DATE" ]; then
echo 'Close to Labor Day! Building for linux/amd64 only for performance reasons.'
echo 'PLATFORMS=linux/amd64' >> "$GITHUB_ENV"
echo 'PLATFORMS=linux/amd64' | tee -a "${GITHUB_ENV}"
else
echo 'PLATFORMS=linux/amd64,linux/arm64' >> "$GITHUB_ENV"
echo 'PLATFORMS=linux/amd64,linux/arm64' | tee -a "${GITHUB_ENV}"
fi
-
name: Build container
Expand All @@ -60,7 +60,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
container: nginx
context: server/nginx
no-cache: true
cache-tag: nginx-latest
tag: ${{ github.ref_name }}

deploy:
Expand Down

0 comments on commit 029c52f

Please sign in to comment.