Skip to content

Commit

Permalink
ci: Separate Release and Build workflow
Browse files Browse the repository at this point in the history
Separate release and build workflows
Trigger workflow only when release is published
  • Loading branch information
coolapso committed Aug 10, 2024
1 parent 332765e commit aa5a757
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 35 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

37 changes: 2 additions & 35 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit aa5a757

Please sign in to comment.