From 1d171f1b38366a21f809f79ae535cc414f85b130 Mon Sep 17 00:00:00 2001 From: Tomas Bezouska Date: Sat, 5 Oct 2024 21:37:09 +0200 Subject: [PATCH] feat(deploy): merge deploy with build --- .github/workflows/build-deploy.yml | 12 +++++-- .github/workflows/build.yml | 53 ------------------------------ Netstr.sln | 1 - 3 files changed, 9 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index c3f2298..193dbaa 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -2,7 +2,7 @@ name: Build & Deploy on: push: - branches: [ main ] + pull_request: jobs: build: @@ -36,8 +36,14 @@ jobs: - name: Get docker tag id: tag - run: echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT - + run: | + echo "${GITHUB_REF##*/}" + if [[ "${GITHUB_REF##*/}" == "main" ]]; then + echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT + else + echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT + fi + - name: Build and push id: docker_build uses: docker/build-push-action@v6 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 615637f..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build - -on: - push: - branches: - - '!main' - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - permissions: - packages: write - outputs: - image-tag: ${{ steps.tag.outputs.IMAGE_TAG }} - steps: - - name: Check Out Repo - uses: actions/checkout@v4 - - - name: Login to Github Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: bezysoftware - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Get docker tag - id: tag - run: echo "IMAGE_TAG=${GITHUB_SHA}" >> $GITHUB_OUTPUT - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v6 - with: - context: ./ - file: ./Dockerfile - builder: ${{ steps.buildx.outputs.name }} - push: true - tags: ghcr.io/bezysoftware/netstr:${{ steps.tag.outputs.IMAGE_TAG }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/Netstr.sln b/Netstr.sln index 4d22922..20c0a78 100644 --- a/Netstr.sln +++ b/Netstr.sln @@ -23,7 +23,6 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{320F094E-4B63-40D7-8D8B-AB5B01F6FCB0}" ProjectSection(SolutionItems) = preProject .github\workflows\build-deploy.yml = .github\workflows\build-deploy.yml - .github\workflows\build.yml = .github\workflows\build.yml .github\workflows\manual.yml = .github\workflows\manual.yml .github\workflows\release.yml = .github\workflows\release.yml EndProjectSection