Browse Source

Merge pull request #129 from gravitl/github-action

GitHub action updates
Alex 4 years ago
parent
commit
1f907651ac
2 changed files with 18 additions and 19 deletions
  1. 0 5
      .github/workflows/buildandrelease.yml
  2. 18 14
      .github/workflows/publish-docker.yml

+ 0 - 5
.github/workflows/buildandrelease.yml

@@ -41,7 +41,6 @@ jobs:
           env GOOS=linux GOARCH=arm64 go build -o build/netclient-arm64/netclient main.go
 
       - name: Upload x86 to Release
-        if: github.event.inputs.version == ''
         uses: svenstaro/upload-release-action@v2
         with:
           repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -52,7 +51,6 @@ jobs:
           asset_name: netclient
 
       - name: Upload arm5 to Release
-        if: github.event.inputs.version == ''
         uses: svenstaro/upload-release-action@v2
         with:
           repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -63,7 +61,6 @@ jobs:
           asset_name: netclient-arm5
 
       - name: Upload arm6 to Release
-        if: github.event.inputs.version == ''
         uses: svenstaro/upload-release-action@v2
         with:
           repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -74,7 +71,6 @@ jobs:
           asset_name: netclient-arm6
 
       - name: Upload arm7 to Release
-        if: github.event.inputs.version == ''
         uses: svenstaro/upload-release-action@v2
         with:
           repo_token: ${{ secrets.GITHUB_TOKEN }}
@@ -85,7 +81,6 @@ jobs:
           asset_name: netclient-arm7
 
       - name: Upload arm64 to Release
-        if: github.event.inputs.version == ''
         uses: svenstaro/upload-release-action@v2
         with:
           repo_token: ${{ secrets.GITHUB_TOKEN }}

+ 18 - 14
.github/workflows/publish-docker.yml

@@ -1,15 +1,30 @@
 name: Publish Docker
 
 on:
+  workflow_dispatch:
+    inputs:
+      tag:
+        description: 'docker tag'
+        required: true
   pull_request:
     branches:
-      - 'develop'
+      - 'test'
       - 'master'
-      
+
 jobs:
   docker:
     runs-on: ubuntu-latest
     steps:
+      - name: Set tag
+        run: |
+            if [[ -n "${{ github.event.inputs.tag }}" ]]; then
+              TAG=${{ github.event.inputs.tag }}
+            elif [[ "${{ github.base_ref }}" == 'master' ]]; then
+              TAG="latest"
+            else
+              TAG="${{ github.base_ref }}"
+            fi
+            echo "TAG=${TAG}" >> $GITHUB_ENV
       - name: Checkout
         uses: actions/checkout@v2
       - name: Set up QEMU
@@ -22,20 +37,9 @@ jobs:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
       - name: Build and push latest
-        if: github.base_ref == 'master'
-        uses: docker/build-push-action@v2
-        with:
-          context: .
-          platforms: linux/amd64, linux/arm64
-          push: true
-          tags: |
-            gravitl/netmaker:latest
-      - name: Build and push develop
-        if: github.base_ref == 'develop'
         uses: docker/build-push-action@v2
         with:
           context: .
           platforms: linux/amd64, linux/arm64
           push: true
-          tags: |
-            gravitl/netmaker:develop
+          tags: gravitl/netmaker:${{ env.TAG }}