-
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.
- Loading branch information
Showing
1 changed file
with
53 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,53 @@ | ||
name: Build the container | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build_container: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup access to GitHub registry | ||
run: | | ||
echo "CI_REGISTRY_IMAGE=ghcr.io/${GITHUB_REPOSITORY}" >> $GITHUB_ENV | ||
cat <<JSON > config.json | ||
{ | ||
"auths": { | ||
"ghcr.io": { | ||
"username": "$GITHUB_ACTOR", | ||
"password": "${{ secrets.GITHUB_TOKEN }}" | ||
} | ||
} | ||
} | ||
JSON | ||
- name: Build the container | ||
run: | | ||
docker run \ | ||
-v $GITHUB_WORKSPACE:/workspace \ | ||
-v $GITHUB_WORKSPACE/config.json:/kaniko/.docker/config.json:ro \ | ||
gcr.io/kaniko-project/executor:latest \ | ||
--context dir:///workspace/ \ | ||
--dockerfile Dockerfile \ | ||
--cache \ | ||
--push-retry 3 \ | ||
--destination="${{ env.CI_REGISTRY_IMAGE }}:$GITHUB_SHA" \ | ||
--destination="${{ env.CI_REGISTRY_IMAGE }}:latest" | ||
tag_container: | ||
if: github.ref_name == 'main' | ||
runs-on: ubuntu-latest | ||
|
||
needs: build_container | ||
|
||
steps: | ||
# Install crane | ||
- uses: imjasonh/[email protected] | ||
|
||
- name: Tag the image as stable and with a datetime | ||
run: | | ||
crane tag "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA}" "stable" | ||
crane tag "ghcr.io/${GITHUB_REPOSITORY}:${GITHUB_SHA}" "$(date +%Y%m%d-%H%M%S)" |