Skip to content

Commit

Permalink
fix(ci): Change CI workflow
Browse files Browse the repository at this point in the history
Create 1>n workflow to be able to release then to build on multiple
versions.
Change base image to alpine.
  • Loading branch information
germainlefebvre4 committed Oct 26, 2020
1 parent d1cd163 commit b66905b
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 151 deletions.
File renamed without changes.
43 changes: 43 additions & 0 deletions .github/workflows/master-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and publish Docker images

on:
workflow_dispatch:
inputs:
release:
description: Release name
required: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
kubectl_version:
- 1.19.3
- 1.18.10
- 1.17.13
- 1.16.15
- 1.15.12
- 1.14.10
- 1.13.12
steps:
- uses: actions/checkout@v1

- name: Publish to Docker Repository
uses: elgohr/Publish-Docker-Github-Action@master
env:
KUBECTL_VERSION: ${{ matrix.kubectl_version }}
with:
name: germainlefebvre4/ns-killer
buildargs: KUBECTL_VERSION
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
tags: "${{ github.event.inputs.release }}-kubectl${{ matrix.kubectl_version }},${{ github.event.inputs.release }}-${{ matrix.kubectl_version }},latest-kubectl${{ matrix.kubectl_version }},latest-${{ matrix.kubectl_version }},${{ matrix.kubectl_version }}"

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v2
with:
repository: germainlefebvre4/ns-killer
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD2 }}
readme-filepath: ./docs/dockerhub/README.md
45 changes: 45 additions & 0 deletions .github/workflows/master-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Semantic Release Config
run: |
echo '{
"tagFormat":"v${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/github"
]
}
'> .releaserc
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
branches: 'master'
semantic_version: 17.1.1
extra_plugins: |
@semantic-release/commit-analyzer@8.0.1
@semantic-release/release-notes-generator@9.0.0
@semantic-release/changelog@5.0.0
@semantic-release/github@7.0.7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Workflow Dispatch
uses: benc-uk/workflow-dispatch@v1.1
with:
workflow: Build and publish Docker images
token: ${{ secrets.PERSONAL_TOKEN }}
inputs: '{ "release": "${{ steps.semantic.outputs.new_release_version }}" }'
69 changes: 0 additions & 69 deletions .github/workflows/release-master.yml

This file was deleted.

18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM python:3.7-slim-stretch AS base
FROM python:3.7-alpine AS base

ENV PYROOT /pyroot
ENV PYTHONUSERBASE $PYROOT


FROM base as builder

RUN apt update && \
apt install -y python-pip && \
apt -y clean && \
RUN apk update && \
apk add --no-cache py-pip && \
pip install pipenv

# Update pipenv libs
Expand All @@ -21,12 +20,15 @@ FROM base
ARG KUBECTL_VERSION=1.14.10

# Kubectl
RUN apt update && apt install -y curl && \
curl -Lo /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \
RUN apk update && \
apk add curl && \
curl -Lo /tmp/kubernetes-client-linux-amd64.tar.gz https://dl.k8s.io/v${KUBECTL_VERSION}/kubernetes-client-linux-amd64.tar.gz && \
tar -zxvf /tmp/kubernetes-client-linux-amd64.tar.gz -C /tmp && \
mv /tmp/kubernetes/client/bin/kubectl /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl

# Python libs and sources
COPY --from=builder $PYROOT/lib/ $PYROOT/lib/
COPY main.py .
COPY . .

CMD ["python", "main.py"]
CMD ["python", "handler.py"]
3 changes: 1 addition & 2 deletions docs/dockerhub/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Supported tags and respective `Dockerfile` links
* [latest](Dockerfile)
* `1.0.0-kubectl1.19.3`, `1.0.0-1.19.3`, `1.0.0`, `latest`
* `1.0.0-kubectl1.19.3`, `1.0.0-1.19.3`, `1.0.0`, [`latest`](Dockerfile)
* `1.0.0-kubectl1.18.10`, `1.0.0-1.18.10`
* `1.0.0-kubectl1.17.13`, `1.0.0-1.17.13`
* `1.0.0-kubectl1.16.15`, `1.0.0-1.16.15`
Expand Down
72 changes: 0 additions & 72 deletions main.py.trash

This file was deleted.

0 comments on commit b66905b

Please sign in to comment.