From 90a8a5b76ecc9f487527ad43ba49d3b2ab8c49ee Mon Sep 17 00:00:00 2001 From: bilalrao12 <118199337+bilalrao12@users.noreply.github.com> Date: Tue, 8 Oct 2024 18:44:17 +0500 Subject: [PATCH] Update ghcr.yml (#557) push deb and rpm amd64 packages to packagecloud check secret existence before pushing to dockerhub --- .github/workflows/ghcr.yml | 57 +++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 7b0f376..ebd4817 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -69,6 +69,40 @@ jobs: with: args: 'heplify-server*' + - name: Check PACKAGECLOUD secret presence + id: checkpackagecloud + shell: bash + run: | + if [ "$SECRET" == "" ] || [ "$USERNAME" == "" ]; then + echo "secretspresent=false" >> $GITHUB_OUTPUT + else + echo "secretspresent=true" >> $GITHUB_OUTPUT + fi + env: + SECRET: ${{ secrets.PACKAGECLOUD_TOKEN }} + USERNAME: ${{ secrets.PACKAGECLOUD_USERNAME }} + + - name: upload deb packagecloud + if: ${{ matrix.arch != 'aarch64' && steps.checkpackagecloud.outputs.secretspresent == 'true' }} + uses: danielmundi/upload-packagecloud@v1 + with: + PACKAGE-NAME: heplify-server-*-amd64.deb + PACKAGECLOUD-REPO: sipcapture + PACKAGECLOUD-DISTRIB: any/any + PACKAGECLOUD-USERNAME: ${{ secrets.PACKAGECLOUD_USERNAME }} + PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} + continue-on-error: true + + - name: upload rpm packagecloud + if: ${{ matrix.arch != 'aarch64' && steps.checkpackagecloud.outputs.secretspresent == 'true' }} + uses: danielmundi/upload-packagecloud@v1 + with: + PACKAGE-NAME: heplify-server-*-amd64.rpm + PACKAGECLOUD-REPO: sipcapture + PACKAGECLOUD-DISTRIB: rpm_any/rpm_any + PACKAGECLOUD-USERNAME: ${{ secrets.PACKAGECLOUD_USERNAME }} + PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }} + continue-on-error: true docker-ghcr-push: if: ${{ github.event_name != 'workflow_dispatch' }} @@ -120,6 +154,19 @@ jobs: contents: read steps: + - name: Check Docker secret presence + id: checkdocker + shell: bash + run: | + if [ "$SECRET" == "" ] || [ "$USERNAME" == "" ]; then + echo "secretspresent=false" >> $GITHUB_OUTPUT + else + echo "secretspresent=true" >> $GITHUB_OUTPUT + fi + env: + SECRET: ${{ secrets.DOCKERHUB_TOKEN }} + USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + - uses: actions/checkout@v3 - name: Version Check run: | @@ -133,10 +180,18 @@ jobs: uses: docker/setup-buildx-action@v3.0.0 - name: Login to DockerHub + id: logintodocker + if: ${{ steps.checkdocker.outputs.secretspresent == 'true' }} uses: docker/login-action@v3.2.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Exit if credentials doesn't exist + if: ${{ steps.checkdocker.outputs.secretspresent == 'false' }} + run: | + echo "can not proceed" + exit 1 - name: Build and push to DockerHub uses: docker/build-push-action@v5.0.0