From 0694ebd64277e418b60f97baabe173f646c1c6a0 Mon Sep 17 00:00:00 2001 From: Ben Coleman Date: Tue, 13 Oct 2020 16:34:19 +0100 Subject: [PATCH] CI/CD reworking --- .github/workflows/docker-ci-build.yml | 32 +++++++++++-------------- .github/workflows/docker-release.yml | 34 +++++++++++++-------------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/.github/workflows/docker-ci-build.yml b/.github/workflows/docker-ci-build.yml index fa68c48..d6e73eb 100644 --- a/.github/workflows/docker-ci-build.yml +++ b/.github/workflows/docker-ci-build.yml @@ -1,33 +1,29 @@ name: Build Dockerhub Image -on: - push: +on: + push: branches: [master] pull_request: branches: [master] - + env: - dockerUser: bencuk imageName: kubeview imageTag: latest - + jobs: buildJob: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v1 + + - name: Check server code with gofmt + run: bash .github/workflows/gofmt-action.sh cmd/server - - name: Check server code with gofmt - run: bash .github/workflows/gofmt-action.sh cmd/server + - name: Build the Docker image + run: docker build . --file ./build/Dockerfile --build-arg buildInfo="GitHub CI build $GITHUB_RUN_ID, of $GITHUB_REF on $(date -I)" --tag ghcr.io/$GITHUB_ACTOR/$imageName:$imageTag - - name: Build the Docker image - run: docker build . --file ./build/Dockerfile --build-arg buildInfo="GitHub CI build $GITHUB_RUN_ID, of $GITHUB_REF on $(date -I)" --tag $dockerUser/$imageName:$imageTag - - - name: Login to Dockerhub - if: github.repository == 'benc-uk/kubeview' && github.event_name == 'push' - run: docker login -u $dockerUser -p ${{ secrets.dockerPassword }} - - - name: Push to Dockerhub - if: github.repository == 'benc-uk/kubeview' && github.event_name == 'push' - run: docker push $dockerUser/$imageName:$imageTag + - name: Push to Github registry + run: | + echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin + docker push ghcr.io/$GITHUB_ACTOR/$imageName:$imageTag diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index d994ac6..421ca71 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -16,25 +16,25 @@ jobs: steps: - uses: actions/checkout@v1 - # - name: Build the Docker image - # run: docker build . --file ./build/Dockerfile --build-arg version="${{ github.event.release.tag_name }}" --build-arg buildInfo="GitHub release build dated:$(date -I)" --tag $dockerUser/$imageName:${{ github.event.release.tag_name }} + - name: Build the Docker image + run: docker build . --file ./build/Dockerfile --build-arg version="${{ github.event.release.tag_name }}" --build-arg buildInfo="GitHub release build dated:$(date -I)" --tag ghcr.io/$GITHUB_ACTOR/$imageName:${{ github.event.release.tag_name }} - # - name: Login to Dockerhub - # run: docker login -u $dockerUser -p ${{ secrets.dockerPassword }} - - # - name: Push to Dockerhub - # run: docker push $dockerUser/$imageName:${{ github.event.release.tag_name }} + - name: Push to Github registry + run: | + echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin + docker push ghcr.io/$GITHUB_ACTOR/$imageName:${{ github.event.release.tag_name }} - name: Package Helm chart run: helm package kubeview --version 0.0.0 working-directory: ./deployments/helm - # - name: Upload extension package to release - # id: upload-release-asset - # uses: actions/upload-release-asset@v1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # upload_url: ${{ github.event.release.upload_url }} - # asset_path: ./deployments/helm/kubeview-${{ github.event.release.tag_name }}.tgz - # asset_name: kubeview-${{ github.event.release.tag_name }}.tgz - # asset_content_type: application/octet-stream + + - name: Upload Helm chart to release + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./deployments/helm/kubeview-0.0.0.tgz + asset_name: kubeview-${{ github.event.release.tag_name }}.tgz + asset_content_type: application/octet-stream