From aa5a757783bce41c6d31f2861f37b07ba0d953d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Cola=C3=A7o?= Date: Sat, 10 Aug 2024 17:58:44 +0200 Subject: [PATCH] ci: Separate Release and Build workflow Separate release and build workflows Trigger workflow only when release is published --- .github/workflows/docker.yaml | 36 +++++++++++++++++++++++++++++++++ .github/workflows/release.yaml | 37 ++-------------------------------- 2 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..821e50c --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,36 @@ +name: Docker +on: + workflow_dispatch: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-tags: true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: set tag + run: echo "DOCKER_TAG=$(git describe --tags --abbrev=0 | sed -E 's/^v//g')" >> $GITHUB_ENV + + - name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: coolapso/twitch-exporter:latest,coolapso/twitch-exporter:${{ env.DOCKER_TAG }} + diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f13b398..15dbb92 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,42 +26,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - docker: - runs-on: ubuntu-latest - needs: release - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: set docker tag - run: | - DOCKER_TAG=${{ needs.release.outputs.version }} - if [[ -z $DOCKER_TAG]]; - DOCKER_TAG=$(git describe --long --tags --abbrev=8 --exclude='*[a-zA-Z][a-zA-Z]*' | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g') - fi - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v6 - with: - platforms: linux/amd64,linux/arm64,linux/arm/v7 - push: true - tags: coolapso/twitch-exporter:latest,coolapso/twitch-exporter:${DOCKER_TAG} - - - name: Docker Hub Description + - name: Update Docker Hub Description uses: peter-evans/dockerhub-description@v4 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} repository: coolapso/twitch-exporter