-
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 develop Docker image release flow (#17)
- Loading branch information
Showing
4 changed files
with
103 additions
and
15 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,92 @@ | ||
--- | ||
name: Docker build and push | ||
|
||
inputs: | ||
github-token: | ||
required: true | ||
image_tag: | ||
required: false | ||
type: string | ||
dockerfile: | ||
required: false | ||
type: string | ||
default: "Dockerfile" | ||
build-args: | ||
required: false | ||
type: string | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ inputs.github-token }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/${{ github.repository }}/s | ||
github-token: ${{ inputs.github-token }} | ||
|
||
- name: Image tag | ||
shell: bash | ||
run: | | ||
REPOSITORY_NAME="$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" | ||
if [ -z ${{ inputs.image_tag }} ]; then | ||
BUILD_TIMESTAMP="$(date +%s)" | ||
SHORT_SHA="$(git rev-parse --short HEAD)" | ||
echo GHCR_TAG="ghcr.io/${{ github.repository }}/immutable-geth:develop-$BUILD_TIMESTAMP-git.$SHORT_SHA" >> $GITHUB_ENV | ||
else | ||
echo GHCR_TAG="ghcr.io/${{ github.repository }}/immutable-geth:${{ inputs.image_tag }}" >> $GITHUB_ENV | ||
fi | ||
- name: Restore Go mod (pkg) | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: "~/go/pkg/mod" | ||
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}-${{ github.sha }}-${{ github.run_id }} | ||
restore-keys: | | ||
${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}-${{ github.sha }}- | ||
${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}- | ||
${{ runner.os }}-gomod- | ||
- name: Restore Go build (test) | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: "~/.cache/go-build" | ||
key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }}-${{ github.sha }}-${{ github.run_id }} | ||
restore-keys: | | ||
${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }}-${{ github.sha }}- | ||
${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }}- | ||
${{ runner.os }}-gobuild- | ||
- name: Set up Docker Context for buildx | ||
id: buildx-context | ||
shell: bash | ||
run: | | ||
docker context create builders | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
version: latest | ||
endpoint: builders | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
file: ${{ inputs.dockerfile }} | ||
push: true | ||
build-args: ${{ inputs.build-args }} | ||
tags: ${{ env.GHCR_TAG }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/immutable-geth:cache | ||
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/immutable-geth:cache,mode=max | ||
provenance: false |
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