-
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
5 changed files
with
118 additions
and
5 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,33 @@ | ||
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: "1.21" | ||
- 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 | ||
push: false |
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,66 @@ | ||
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" | ||
value: ${{ steps.extract.outputs.build }} | ||
push: | ||
description: "push is needed" | ||
value: ${{ steps.extract.outputs.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 | ||
# echo "build=true" >> $GITHUB_OUTPUT | ||
# if [ "${EVENT_NAME}" != "pull_request" ]; then | ||
# echo "push=true" >> $GITHUB_OUTPUT | ||
# fi | ||
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: | ||
EVENT_NAME: ${{ github.event_name }} | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
- 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} |
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"] |