-
Notifications
You must be signed in to change notification settings - Fork 2
Draft: [CI/CD] Build docker container and deploy to kube #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4717a09
616ef16
1e78d4b
b6dae99
fd7ce2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| image_name: | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| DOCKERHUB_USERNAME: | ||
| required: true | ||
| DOCKERHUB_TOKEN: | ||
| required: true | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get sources | ||
| uses: actions/checkout@v4 | ||
| - name: Container meta | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: | | ||
| ${{ inputs.image_name }} | ||
| tags: | | ||
| type=schedule | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=semver,pattern={{version}} | ||
| type=semver,pattern={{major}}.{{minor}} | ||
| type=semver,pattern={{major}} | ||
| type=sha | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Build and push | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| push: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: ./.github/workflows/build-image.yml | ||
| with: | ||
| image_name: zinstack625/iscraweb-ttbot | ||
| secrets: | ||
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Deploy to bleeding edge | ||
| uses: grebois/kube-tools@v1.5.2 | ||
| env: | ||
| KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }} | ||
| with: | ||
| kubectl: 1.18.2 | ||
| command: | | ||
| echo -n "$KUBECONFIG_FILE" > .kubeconfig | ||
| export KUBECONFIG=$(pwd)/.kubeconfig | ||
| kubectl rollout restart -n iscrawebtt deployment ttbot-bleed | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same goes for line 26: kubectl rollout restart -n $NAMESPACE $RESOURCE_TYPE $RESOURCE |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| on: | ||
| workflow_dispatch | ||
|
|
||
| jobs: | ||
| build: | ||
| uses: ./.github/workflows/build-image.yml | ||
| with: | ||
| image_name: zinstack625/iscraweb-ttbot | ||
| secrets: | ||
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to stable | ||
| uses: grebois/kube-tools@v1.5.2 | ||
| env: | ||
| KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }} | ||
| with: | ||
| kubectl: 1.18.2 | ||
| command: | | ||
| echo -n "$KUBECONFIG_FILE" > .kubeconfig | ||
| export KUBECONFIG=$(pwd)/.kubeconfig | ||
| kubectl rollout restart -n iscrawebtt deployment ttbot |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "refresh_period" : $REFRESH_PERIOD, | ||
| "sleep_timeout" : $SLEEP_TIMEOUT, | ||
| "notify_period" : $NOTIFY_PERIOD, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line (4) should be removed if we're going to rely on cron (I suppose it's better). Or it should look like this (if we rely on internal implementation): "notify_schedule" : ["09:00", "21:00"], |
||
| "use_https" : $HTTPS, | ||
| "redmine_root_url" : "$REDMINE_URL", | ||
| "user_db_path" : "./udb/localbase.json", | ||
| "scenery_path" : "./scenery.json", | ||
| "allowed_api_functions" : [], | ||
| "address" : "0.0.0.0", | ||
| "port" : 43210 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/usr/bin/env sh | ||
|
|
||
| [ -z "$CONTAINER_NAME" ] && CONTAINER_NAME=docker.io/Fe-Ti/iscraweb-ttbot:latest | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's better to stop execution with error instead of hardcoding a link*: die() {
echo "$1"; exit 1
}
[ -z "$CONTAINER_NAME" ] && die 'CONTAINER_NAME is not set! Set envvar $CONTAINER_NAME'
|
||
|
|
||
| runner_args=(run --rm -v $(git rev-parse --show-toplevel)/config.json.tmpl:/config.json.tmpl -e REDMINE_URL=$REDMINE_URL -e CFG=/config.json.tmpl -e K=$K -e T=$T "$CONTAINER_NAME") | ||
|
|
||
| case "$CONTAINER_RUNTIME" in | ||
| podman) | ||
| podman ${runner_args[@]};; | ||
| *) | ||
| docker ${runner_args[@]};; | ||
| esac | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. here could be something like