From 78e9db49f07241d77bc3f0ddfdb496951902411a Mon Sep 17 00:00:00 2001 From: Daniel Federschmidt Date: Wed, 28 Apr 2021 14:50:42 +0200 Subject: [PATCH] separate workflow for tagged release --- .github/workflows/main_ci.yml | 2 - .github/workflows/tagged_ci.yml | 111 ++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/tagged_ci.yml diff --git a/.github/workflows/main_ci.yml b/.github/workflows/main_ci.yml index babeea8..c549242 100644 --- a/.github/workflows/main_ci.yml +++ b/.github/workflows/main_ci.yml @@ -3,8 +3,6 @@ name: Main Branch CI on: push: branches: master - tags: - - '*' jobs: test: runs-on: ubuntu-latest diff --git a/.github/workflows/tagged_ci.yml b/.github/workflows/tagged_ci.yml new file mode 100644 index 0000000..5e01018 --- /dev/null +++ b/.github/workflows/tagged_ci.yml @@ -0,0 +1,111 @@ +name: Main Branch CI + +on: + push: + tags: + - "v*" +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry pytest + poetry install + - name: Test with pytest + env: + SECRET_KEY: TestKey + DATABASE_URL: sqlite:///db.sqlite3 + DEBUG: true + run: | + poetry run pytest + + + docker: + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=ghcr.io/splunk/urlprompt + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + fi + if [ "${{ github.event_name }}" = "schedule" ]; then + VERSION=nightly + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:latest" + fi + echo ::set-output name=tags::${TAGS} + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to ghcr + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + - + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Create ZIP packages + run: | + cd compose && zip -r docker-compose-standalone.zip standalone/* + zip -r docker-compose-proxy.zip proxy/* + + - name: Automatic Releases + uses: marvinpinto/action-automatic-releases@v1.1.2 + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + title: "Development Build" + files: | + LICENSE.txt + compose/docker-compose-standalone.zip + compose/docker-compose-proxy.zip