From b11b7f431e31a5ced32ff4192a09b99519d51162 Mon Sep 17 00:00:00 2001 From: wernerfred <20406381+wernerfred@users.noreply.github.com> Date: Sat, 7 Aug 2021 22:35:29 +0200 Subject: [PATCH] feat: add github workflows --- .github/workflows/docker-image-ci.yml | 32 +++++++++++++++++++ .github/workflows/docker-image-push.yml | 42 +++++++++++++++++++++++++ .github/workflows/github-release.yml | 28 +++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .github/workflows/docker-image-ci.yml create mode 100644 .github/workflows/docker-image-push.yml create mode 100644 .github/workflows/github-release.yml diff --git a/.github/workflows/docker-image-ci.yml b/.github/workflows/docker-image-ci.yml new file mode 100644 index 0000000..4ad11ce --- /dev/null +++ b/.github/workflows/docker-image-ci.yml @@ -0,0 +1,32 @@ +name: Docker Image CI + +on: + push: + branches: [master] + paths: + - "Dockerfile" + - "app/**" + pull_request: + branches: [master] + paths: + - "Dockerfile" + - "app/**" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - name: Lint Dockerfile using hadolint + uses: burdzwastaken/hadolint-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + HADOLINT_ACTION_DOCKERFILE_FOLDER: . + + build: + runs-on: ubuntu-latest + needs: lint + steps: + - uses: actions/checkout@v2.3.4 + - name: Build docker image + run: docker build . diff --git a/.github/workflows/docker-image-push.yml b/.github/workflows/docker-image-push.yml new file mode 100644 index 0000000..e1e8be4 --- /dev/null +++ b/.github/workflows/docker-image-push.yml @@ -0,0 +1,42 @@ +name: Build current version + push to DockerHub + +on: + release: + types: [published] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v3.4.1 + with: + images: wernerfred/docker-nilan-cts700 + tags: | + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{version}} + flavor: | + latest=auto + - name: Set up QEMU + uses: docker/setup-qemu-action@v1.2.0 + with: + image: tonistiigi/binfmt:latest + platforms: amd64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1.5.1 + - name: Login to DockerHub + uses: docker/login-action@v1.10.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.docker_meta.outputs.tags }} diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml new file mode 100644 index 0000000..4d20e98 --- /dev/null +++ b/.github/workflows/github-release.yml @@ -0,0 +1,28 @@ +name: Create GitHub release + +on: + push: + tags: + - "*.*.*" + +jobs: + release: + if: github.event.base_ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + with: + fetch-depth: "0" + + - name: Create Release + id: create_release + uses: actions/create-release@v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN_NILAN_CTS700 }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: "" + draft: false + prerelease: false