mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
ci: build once on tagged commits, bump docker actions
This commit is contained in:
@@ -12,12 +12,35 @@ env:
|
|||||||
DOCKERHUB_REPO: yoursfunny/telegram-twitter-media-bot
|
DOCKERHUB_REPO: yoursfunny/telegram-twitter-media-bot
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# A tag push and a branch push to the same commit fire two workflow runs;
|
||||||
|
# build only once. Tag runs always build; master runs build only when the
|
||||||
|
# pushed commit is not already tagged (the tag run covers it).
|
||||||
|
should-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
build: ${{ steps.check.outputs.build }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- id: check
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "$GITHUB_REF_TYPE" = "branch" ] && git tag --points-at "$GITHUB_SHA" | grep -q .; then
|
||||||
|
echo "commit already tagged; the tag run builds the image"
|
||||||
|
echo "build=false" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "build=true" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
|
needs: should-build
|
||||||
|
if: needs.should-build.outputs.build == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v6
|
||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKERHUB_REPO }}
|
images: ${{ env.DOCKERHUB_REPO }}
|
||||||
tags: |
|
tags: |
|
||||||
@@ -28,19 +51,19 @@ jobs:
|
|||||||
type=sha
|
type=sha
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v4
|
||||||
-
|
-
|
||||||
name: Set up Docker Buildx
|
name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v4
|
||||||
-
|
-
|
||||||
name: Login to Docker Hub
|
name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
-
|
-
|
||||||
name: Build and push
|
name: Build and push
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v7
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
build-args: |
|
build-args: |
|
||||||
|
|||||||
Reference in New Issue
Block a user