-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daichi Sakaue <[email protected]>
- Loading branch information
Showing
8 changed files
with
189 additions
and
51 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,52 @@ | ||
name: "Build admission" | ||
description: "Build admission" | ||
inputs: | ||
github_token: | ||
description: "GitHub Token" | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup build environment | ||
uses: ./.github/actions/setup | ||
with: | ||
github_token: ${{ inputs.github_token }} | ||
go-version-file: admission/go.mod | ||
- id: extract | ||
name: Extract targets | ||
uses: ./.github/actions/extract_tags | ||
with: | ||
container-image: admission | ||
github_token: ${{ inputs.github_token }} | ||
# - name: Run check-generate | ||
# if: ${{ steps.extract.outputs.build }} | ||
# shell: bash | ||
# run: make check-generate | ||
# working-directory: admission | ||
# - name: Test | ||
# if: ${{ steps.extract.outputs.build }} | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# context: admission | ||
# platforms: "linux/amd64" | ||
# target: test | ||
# provenance: false | ||
# push: false | ||
- name: Test | ||
if: ${{ steps.extract.outputs.build }} | ||
shell: bash | ||
run: | | ||
make check-generate | ||
make test | ||
working-directory: admission | ||
- name: Build and push | ||
if: ${{ steps.extract.outputs.build }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: admission | ||
platforms: "linux/amd64" | ||
provenance: false | ||
push: ${{ steps.extract.outputs.docker_push }} | ||
tags: | | ||
${{ steps.extract.outputs.tag }} | ||
${{ steps.extract.outputs.branch }} |
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,96 @@ | ||
name: "Extract tags" | ||
description: "Extract tags to use for the new image" | ||
inputs: | ||
dir: | ||
description: "working directory" | ||
required: false | ||
default: "" | ||
container-image: | ||
description: "container image" | ||
required: true | ||
github_token: | ||
description: "GitHub Token" | ||
required: true | ||
outputs: | ||
branch: | ||
description: "branch" | ||
value: ${{ steps.extract.outputs.branch }} | ||
tag: | ||
description: "tag" | ||
value: ${{ steps.extract.outputs.tag }} | ||
build: | ||
description: "build is needed (true or '')" | ||
value: ${{ steps.flags.outputs.build }} | ||
push: | ||
description: "push is needed (true or '')" | ||
value: ${{ steps.flags.outputs.push }} | ||
# docker/build-push-action does not accept '' as its push flag | ||
docker_push: | ||
description: "push is needed (true or false)" | ||
value: ${{ steps.flags.outputs.docker_push }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- id: extract | ||
name: Extract targets | ||
shell: bash | ||
run: | | ||
DIR=${{ inputs.dir }} | ||
if [ "${DIR}" = "" ]; then DIR=${{ inputs.container-image }}; fi | ||
IMAGE=${{ inputs.container-image }} | ||
TAG=$(cat ${DIR}/TAG) | ||
FOUND=$(container-tag-exists ghcr.io/cybozu/${IMAGE} ${TAG}) | ||
# The stdout should be either "" or "found". | ||
if [ "${FOUND}" = "" ]; then | ||
echo "tag=ghcr.io/cybozu/${IMAGE}:${TAG}" >> $GITHUB_OUTPUT | ||
if [ -f ${DIR}/BRANCH ]; then | ||
if echo ${TAG} | grep -q -e - ; then | ||
echo ===== Skip pushing branch tags for pre-release ${TAG} ===== | ||
else | ||
BRANCH=$(cat ${DIR}/BRANCH) | ||
echo "branch=ghcr.io/cybozu/${IMAGE}:${BRANCH}" >> $GITHUB_OUTPUT | ||
fi | ||
fi | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
- id: flags | ||
name: Decide build flags | ||
shell: bash | ||
run: | | ||
if ! [ -z "${{ steps.extract.outputs.tag }}" ]; then | ||
echo "build=true" >> $GITHUB_OUTPUT | ||
if [ "${EVENT_NAME}" != "pull_request" ]; then | ||
echo "push=true" >> $GITHUB_OUTPUT | ||
echo "docker_push=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "docker_push=false" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
echo "docker_push=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
EVENT_NAME: ${{ github.event_name }} | ||
- name: Validate consistency between BRANCH and TAG | ||
shell: bash | ||
run: | | ||
DIR=${{ inputs.dir }} | ||
if [ "${DIR}" = "" ]; then DIR=${{ inputs.container-image }}; fi | ||
if [ -e "${DIR}/NO_TAG_BRANCH_CONSISTENCY" ]; then exit 0; fi | ||
./tag_branch_consistency ${DIR} | ||
- name: Echo output | ||
shell: bash | ||
run: | | ||
echo | ||
echo "vvvvvvvvvv vvvvvvvvvv vvvvvvvvvv vvvvvvvvvv vvvvvvvvvv vvvvvvvvvv" | ||
echo " Build Policy:" | ||
echo | ||
echo " branch: ${{ steps.extract.outputs.branch }}" | ||
echo " tag: ${{ steps.extract.outputs.tag }}" | ||
echo " build: ${{ steps.flags.outputs.build }}" | ||
echo " push: ${{ steps.flags.outputs.push }}" | ||
echo " docker_push: ${{ steps.flags.outputs.docker_push }}" | ||
echo ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ | ||
echo |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
* | ||
!workspace | ||
bin | ||
*.md |
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
FROM scratch | ||
FROM quay.io/cybozu/golang:1.20-jammy AS test | ||
COPY . /work | ||
RUN make test | ||
|
||
COPY workspace/neco-admission /neco-admission | ||
FROM quay.io/cybozu/golang:1.20-jammy AS build | ||
COPY . /work | ||
RUN make build | ||
|
||
FROM scratch | ||
COPY --from=build /work/bin/neco-admission /neco-admission | ||
USER 10000:10000 | ||
|
||
ENTRYPOINT ["/neco-admission"] |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.24.2 | ||
0.24.3 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
0.1.24 | ||
0.1.25 |