From 2e060b6d2551937dfa30fa25ddc071aa2bb03769 Mon Sep 17 00:00:00 2001 From: Dmitry Sergeev Date: Thu, 20 Jun 2024 00:02:40 +0500 Subject: [PATCH] Init --- .github/dependabot.yml | 11 ++++++ .github/workflows/latest.yaml | 38 +++++++++++++++++++++ .github/workflows/release.yaml | 61 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 23 +++++++++++++ Dockerfile | 11 ++++++ 5 files changed, 144 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/latest.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 Dockerfile diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5990d9c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml new file mode 100644 index 0000000..d1007a4 --- /dev/null +++ b/.github/workflows/latest.yaml @@ -0,0 +1,38 @@ +name: container build latest +on: + workflow_run: + workflows: ["Test"] + branches: [main] + types: + - completed + +jobs: + container_image: + name: container_image + if: github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@master + - name: image name + id: set-image-name + run: | + name="$(echo ${{ github.repository }} | tr 'A-Z' 'a-z')" + echo "image=ghcr.io/$name:latest" >> $GITHUB_OUTPUT + + - name: Login to GitHub Container Registry + uses: docker/login-action@master + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@master + with: + context: . + push: true + tags: ${{ steps.set-image-name.outputs.image }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..62e714b --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,61 @@ +name: release +concurrency: + group: release + cancel-in-progress: true +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+*' +jobs: + container_image: + name: container_image + runs-on: ubuntu-latest + outputs: + image: ${{ steps.set-image-name.outputs.image }} + steps: + - name: Checkout code + uses: actions/checkout@main + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@master + - name: image name + id: set-image-name + run: | + name="$(echo ${{ github.repository }} | tr 'A-Z' 'a-z')" + echo "image=ghcr.io/$name:${{ github.ref_name }}" >> $GITHUB_OUTPUT + + - name: Login to GitHub Container Registry + uses: docker/login-action@master + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@master + with: + context: . + push: true + tags: ${{ steps.set-image-name.outputs.image }} + cache-from: type=gha + cache-to: type=gha,mode=max + + release: + name: release + runs-on: ubuntu-latest + needs: [container_image] + steps: + - name: download cache-artifacts + uses: actions/cache/restore@main + with: + path: ./artifacts + key: artifacts + + - name: ${{ github.ref_name }} + uses: softprops/action-gh-release@v2 + with: + body: | + container image: + ``` + ${{ needs.container_image.outputs.image }} + ``` + files: | + ./artifacts/* diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..67555f6 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,23 @@ +name: Test +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@master + + - name: Build container + uses: docker/build-push-action@master + with: + context: . + push: false + tags: test + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12b5aeb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM docker.io/nginx:1.27.0-alpine3.19-slim as copy + +FROM docker.io/alpine:3.20.0 as settings +RUN apk --no-cache add libcap +COPY --from=copy /usr/sbin/nginx /usr/sbin/nginx +RUN setcap cap_net_bind_service+ep /usr/sbin/nginx + +FROM docker.io/nginx:1.27.0-alpine3.19-slim +COPY --from=settings /usr/sbin/nginx /usr/sbin/nginx + +