Split docker images generation into separate workflows

This commit is contained in:
Bubka 2022-05-13 10:45:00 +02:00
parent 7cc7b7efc2
commit 346d50bdc2
3 changed files with 69 additions and 44 deletions

View File

@ -1,4 +1,4 @@
name: CI
name: ci-docker-latest
on:
push:
branches:
@ -86,33 +86,23 @@ jobs:
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set variables
id: vars
id: set_vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
BRANCH=${GITHUB_REF#refs/heads/}
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=created::$(date -u +%Y-%m-%dT%H:%M:%SZ)
if [ "$TAG" != "$GITHUB_REF" ]; then
echo ::set-output name=version::$TAG
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
elif [ "$BRANCH" = "master" ]; then
echo ::set-output name=version::latest
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
else
echo ::set-output name=version::$BRANCH
echo ::set-output name=platforms::linux/amd64
fi
echo ::set-output name=version::latest
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
- name: Build and push final image
- name: Build and push to docker Hub
uses: docker/build-push-action@v2.6.1
with:
platforms: ${{ steps.vars.outputs.platforms }}
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.vars.outputs.created }}
COMMIT=${{ steps.vars.outputs.commit }}
VERSION=${{ steps.vars.outputs.version }}
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_vars.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.vars.outputs.version }}
2fauth/2fauth:${{ steps.set_vars.outputs.version }}
push: true

59
.github/workflows/ci-docker-release.yml vendored Normal file
View File

@ -0,0 +1,59 @@
name: ci-docker-release
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
ref: ${{ github.event.release.tag_name }}
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set version
uses: actions/github-script@v4
id: set_version
with:
script: |
const tag = context.ref.substring(10)
const version = tag.replace('v', '')
core.setOutput('version', version)
- name: Set variables
id: set_vars
env:
EVENT_NAME: ${{ github.event_name }}
run: |
echo ::set-output name=commit::$(git rev-parse --short HEAD)
echo ::set-output name=created::$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v2.4.3
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: 2fauth/2fauth
short-description: A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
readme-filepath: docker/README.md
- name: Build and push to docker Hub
uses: docker/build-push-action@v2.6.1
with:
platforms: ${{ steps.set_vars.outputs.platforms }}
build-args: |
CREATED=${{ steps.set_vars.outputs.created }}
COMMIT=${{ steps.set_vars.outputs.commit }}
VERSION=${{ steps.set_version.outputs.version }}
tags: |
2fauth/2fauth:${{ steps.set_version.outputs.version }}
push: true

View File

@ -1,24 +0,0 @@
name: Docker Hub description
on:
push:
branches: [master]
paths:
- docker/README.md
- .github/workflows/dockerhub-readme.yml
jobs:
dockerHubDescription:
if: |
(github.event_name == 'push' && github.repository == 'Bubka/2fauth') ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'Bubka/2fauth' && github.actor != 'dependabot[bot]')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v2.4.3
with:
username: 2fauth
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: 2fauth/2fauth
short-description: A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
readme-filepath: docker/README.md