Skip to content

add CICD

add CICD #8

Workflow file for this run

name: webhook-workflow
on:
pull_request:
paths:
- operator/webhook/**
- .github/workflows/webhook.yml
env:
WORKING_DIR: ./operator/webhook
REGISTRY: ghcr.io/octoconsulting
IMAGE_NAME: keip/route-webhook
TAG_PREFIX: "webhook_v"
jobs:
test:
name: unit test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: python3 -m pip install -r requirements.txt
- run: python3 -m pip install -r requirements-dev.txt
- run: make test
build:
name: build image
needs: test
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v4
- uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: ${{ env.WORKING_DIR }}
push: false
release:
needs: test
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ env.WORKING_DIR }}
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- run: echo "VERSION=$(cat version.txt)" >> "$GITHUB_OUTPUT"
id: version-selector
name: generate image name
# - run: "! docker manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version-selector.outputs.VERSION }}"
# name: confirm image is not already pushed
- run: |
TAG_NAME=${{ env.TAG_PREFIX }}${{ steps.version-selector.outputs.VERSION }}
git fetch --tags
git rev-parse -q --verify "refs/tags/$TAG_NAME"
name: confirm git tag does not exist
# - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
# with:
# context: ${{ env.WORKING_DIR }}
# push: true
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version-selector.outputs.VERSION }}
#
# - uses: mathieudutour/[email protected]
# id: tag_version
# with:
# custom_tag: ${{ env.TAG_PREFIX }}:${{ steps.version-selector.outputs.VERSION }}
# github_token: ${{ secrets.GITHUB_TOKEN }}
#
# - uses: ncipollo/release-action@v1
# with:
# tag: ${{ steps.tag_version.outputs.new_tag }}
# name: Release ${{ steps.tag_version.outputs.new_tag }}
# body: ${{ steps.tag_version.outputs.changelog }}