From b36829570eaa68d05bb61ff9918a04e81983504b Mon Sep 17 00:00:00 2001 From: Philip Laine Date: Sat, 5 Jun 2021 22:55:39 +0200 Subject: [PATCH] Update publish action --- .github/workflows/publish-helm-charts.yaml | 13 ---- .github/workflows/publish.yaml | 82 ++++++++++++++++++++++ 2 files changed, 82 insertions(+), 13 deletions(-) delete mode 100644 .github/workflows/publish-helm-charts.yaml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish-helm-charts.yaml b/.github/workflows/publish-helm-charts.yaml deleted file mode 100644 index d878bbe..0000000 --- a/.github/workflows/publish-helm-charts.yaml +++ /dev/null @@ -1,13 +0,0 @@ -name: publish-helm-chart -on: - release: - types: [published] -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Publish Helm charts - uses: stefanprodan/helm-gh-pages@master - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..30b2bfe --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,82 @@ +name: publish +on: + release: + types: [published] +env: + NAME: "azdo-proxy" +jobs: + helm: + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v2 + - name: Get GitHub Tag + id: get_tag + run: | + echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" + - name: Publish Helm charts + uses: stefanprodan/helm-gh-pages@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + chart_version: ${{ steps.get_tag.outputs.tag }} + app_version: ${{ steps.get_tag.outputs.tag }} + image: + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v2 + - name: Prepare + id: prep + run: | + VERSION=sha-${GITHUB_SHA::8} + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF/refs\/tags\//} + fi + echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=VERSION::${VERSION} + - name: Get GitHub Tag + id: get_tag + run: | + echo "::set-output name=tag::${GITHUB_REF#refs/tags/}" + - name: Cache container layers + uses: actions/cache@v2.1.4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - name: Build and push container (multi arch) + uses: docker/build-push-action@v2 + with: + push: true + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm/v7,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + tags: ghcr.io/xenitab/${{ env.NAME }}:${{ steps.get_tag.outputs.tag }} + build-args: | + VERSION=${{ steps.prep.outputs.VERSION }} + REVISION=${{ github.sha }} + CREATED=${{ steps.prep.outputs.BUILD_DATE }} + labels: | + org.opencontainers.image.title=${{ github.event.repository.name }} + org.opencontainers.image.description=${{ github.event.repository.description }} + org.opencontainers.image.url=${{ github.event.repository.html_url }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} + - name: Check images + run: | + docker buildx imagetools inspect ghcr.io/xenitab/${{ env.NAME }}:${{ steps.get_tag.outputs.tag }} + docker pull ghcr.io/xenitab/${{ env.NAME }}:${{ steps.get_tag.outputs.tag }}