3 Commits

Author SHA1 Message Date
Ampenberger, Chris
ec0a641f39 add support for building in sub container 2026-02-11 15:38:21 -05:00
2c40422ef2 act-runner examples 2025-12-19 15:54:22 -05:00
5bc1018327 allow for extra build-args 2025-12-16 18:50:43 -05:00
2 changed files with 57 additions and 2 deletions

View File

@@ -31,6 +31,16 @@ on:
required: false required: false
type: string type: string
default: development default: development
extra-build-args:
description: "Extra build args to pass to the Docker build, separate by space"
required: false
type: string
default: ""
subdirectory:
description: "Subdirectory to use for the build context"
required: false
type: string
default: ""
secrets: secrets:
PASSWORD: PASSWORD:
@@ -43,6 +53,7 @@ env:
LABEL: ${{ inputs.package-label }} LABEL: ${{ inputs.package-label }}
ARTIFACT_UPLOAD: ${{ env.ACT_EXEC == 'true' && 'actions/upload-artifact@v2' || 'actions/upload-artifact@v3' }} ARTIFACT_UPLOAD: ${{ env.ACT_EXEC == 'true' && 'actions/upload-artifact@v2' || 'actions/upload-artifact@v3' }}
ARTIFACT_DOWNLOAD: ${{ env.ACT_EXEC == 'true' && 'actions/download-artifact@v2' || 'actions/download-artifact@v3' }} ARTIFACT_DOWNLOAD: ${{ env.ACT_EXEC == 'true' && 'actions/download-artifact@v2' || 'actions/download-artifact@v3' }}
EXTRA_ARGS: ${{ inputs.extra-build-args }}
jobs: jobs:
@@ -71,7 +82,16 @@ jobs:
- name: Build container - name: Build container
run: | run: |
buildah build -f ${{inputs.dockerfile}} --build-arg GIT_TOKEN=${{secrets.GIT_TOKEN}} --build-arg VERSION=${{inputs.version}} -t gitea.ampenberger.com/${{inputs.git_user}}/${PACKAGE_NAME}:${LABEL} [ -n "${{inputs.subdirectory}}" ] && cd ${{inputs.subdirectory}}
# split the extra-args and construct build-arg parameters
set -- ${EXTRA_ARGS}
args=""
for p in "$@"; do
args="$args --build-arg ${p}"
done
buildah build -f ${{inputs.dockerfile}} --build-arg GIT_TOKEN=${{secrets.GIT_TOKEN}} --build-arg VERSION=${{inputs.version}} ${args} -t gitea.ampenberger.com/${{inputs.git_user}}/${PACKAGE_NAME}:${LABEL}
echo "Built ${PACKAGE_NAME}:${LABEL}" echo "Built ${PACKAGE_NAME}:${LABEL}"
buildah images buildah images

View File

@@ -35,5 +35,40 @@ for an example
## Development ## Development
It is possible to refer to a local version of an workflow in the `uses:` clause
for testing purposes:
```
...
uses: './../workflows/.gitea/workflows/simple-container.yaml
...
```
To avoid caching issues always tag a new version and refer to the respective To avoid caching issues always tag a new version and refer to the respective
version with the tag in the consuming workflow. version with the tag in the consuming workflow.
## act-runner
I use `act_runner` to execute builds on the build server. It is possible
to test workflows by downloading a version from [gitea.com/gitea/act_runner/releases](https://gitea.com/gitea/act_runner/releases).
Following are a few use cases that might be helpful for testing:
```
# Default command for running the first workflow matching a push even
act-runner exec \
--artifact-server-path build \ # where to store artifacts
--secret "GIT_TOKEN=${GITEA_TOKEN}" \ # access token for Gitea access
--secret "PASSWORD=${PASSWORD}" \ # to pull the img-builder images
--privileged \ # needed for building containers
--env "GITEA_IP_ADDR=72.74.26.168" \ # need on my ADI mac to resolve the gitea address
--container-daemon-socket /run/docker.sock # location of the podman socket
# When testing a tag push
act-runner exec --privileged --secret GIT_TOKEN=$GITEA_TOKEN --secret PASSWORD=$PASSWORD --artifact-server-path ./build --env "GITHUB_REFS=rests/tags/...."
# to run a particular workflow
act-runner exec --privileged --secret GIT_TOKEN=$GITEA_TOKEN --secret PASSWORD=$PASSWORD --artifact-server-path ./build -W .gitea/workflows/test.yaml
# To test a particular event
act-runner exec --privileged --secret GIT_TOKEN=$GITEA_TOKEN --secret PASSWORD=$PASSWORD --artifact-server-path ./build -E workfow_dispatch
```