From d3af59b4e063bb5bb8c9b3dd8e7e886474e1a2d9 Mon Sep 17 00:00:00 2001 From: flameshikari Date: Fri, 6 Sep 2024 13:06:40 +0500 Subject: [PATCH] update workflows --- .github/workflows/build.yml | 32 +++++++++++++++----------------- .github/workflows/dry_build.yml | 33 --------------------------------- 2 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/dry_build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7756517..dffdc08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,18 +4,14 @@ on: push: branches: - master + - dev paths: - - .github + - .github/workflows/* - shared - src - Dockerfile workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - jobs: build: name: Build @@ -29,21 +25,23 @@ jobs: with: submodules: recursive - - name: Export variable + - name: Extract Version run: | - echo "VERSION=$(cat src/package.json | jq -r '.version')" >> $GITHUB_ENV + echo "VERSION=$(jq -r '.version' src/package.json)" | tee -a $GITHUB_ENV - name: Setup Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to the GitHub Container Registry + - if: ${{ github.ref == 'refs/heads/master' }} + name: Login to the GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Login to Docker Hub + - if: ${{ github.ref == 'refs/heads/master' }} + name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ github.actor }} @@ -54,8 +52,8 @@ jobs: uses: docker/metadata-action@v5 with: images: | - ${{ env.IMAGE_NAME }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + ${{ github.repository }} + ghcr.io/${{ github.repository }} tags: | type=raw,value=latest type=raw,value=${{ env.VERSION }} @@ -65,13 +63,13 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - push: true + push: ${{ github.ref == 'refs/heads/master' }} cache-from: type=gha cache-to: type=gha,mode=max - tags: - ${{ steps.meta.outputs.tags }} + tags: ${{ steps.meta.outputs.tags }} - - name: Create Release + - if: ${{ github.ref == 'refs/heads/master' }} + name: Create Release uses: softprops/action-gh-release@v2 with: name: ${{ env.VERSION }} diff --git a/.github/workflows/dry_build.yml b/.github/workflows/dry_build.yml deleted file mode 100644 index 3fa4855..0000000 --- a/.github/workflows/dry_build.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Dry Build - -on: - push: - branches: - - dev - paths: - - .github - - shared - - src - - Dockerfile - -jobs: - build: - name: Dry Build - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build Image - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: false - cache-from: type=gha - cache-to: type=gha,mode=max