Skip to content

Commit

Permalink
build(ci): test config
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Apr 1, 2024
1 parent b0cd436 commit 86c9ceb
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
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)"

0 comments on commit 86c9ceb

Please sign in to comment.