55 lines
1.7 KiB
YAML
55 lines
1.7 KiB
YAML
# =============================================================================
|
|
# Gitea Actions workflow (active for THIS repository).
|
|
# Builds examples/Dockerfile and pushes it to Harbor as a smoke test of the
|
|
# k3s runner + DinD + Harbor pipeline.
|
|
#
|
|
# Required repo/org Actions secrets:
|
|
# HARBOR_REGISTRY, HARBOR_USERNAME, HARBOR_PASSWORD
|
|
# Optional repo/org Actions variable:
|
|
# HARBOR_PROJECT (default: "library")
|
|
# =============================================================================
|
|
name: build-and-push
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT || 'library' }}
|
|
IMAGE_NAME: build-on-k3s-sample
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Compute image tags
|
|
id: meta
|
|
run: |
|
|
IMAGE="${{ secrets.HARBOR_REGISTRY }}/${HARBOR_PROJECT}/${IMAGE_NAME}"
|
|
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
|
|
echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Log in to Harbor
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.HARBOR_REGISTRY }}
|
|
username: ${{ secrets.HARBOR_USERNAME }}
|
|
password: ${{ secrets.HARBOR_PASSWORD }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./examples
|
|
file: ./examples/Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.image }}:latest
|
|
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.sha }}
|