Refactoring of github actions files

This commit is contained in:
Totonyus 2024-05-24 18:51:35 +02:00
parent 8cdb619612
commit b670c7cadc
2 changed files with 95 additions and 119 deletions

80
.github/workflows/build_image.yml vendored Normal file
View File

@ -0,0 +1,80 @@
name: Build single image
on:
jobs:
generate_docker_image:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- id: commit
uses: pr-mpt/actions-commit-hash@v1
- name: Extract branch name
shell: bash
id: extract_branch
run: echo ::set-output name=BRANCH_NAME::${GITHUB_REF#refs/*/}
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: readableTime
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image (amd)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
id: build_amd
with:
context: ${{ github.workspace }}
file: dockerfile_amd
platforms: linux/amd64
push: true
tags: totonyus/ydl_api_ng:${{ env.TAG_START }}amd
build-args: |
GIT_BRANCH=${{ steps.extract_branch.outputs.BRANCH_NAME }}
GIT_REVISION=${{ steps.commit.outputs.hash }}
DATE=${{ steps.current-time.outputs.time }}
- name: Build and push Docker image (arm)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
id: build_arm
with:
context: ${{ github.workspace }}
file: dockerfile_arm
platforms: linux/arm/v7,linux/arm64/v8
push: true
tags: totonyus/ydl_api_ng:${{ env.TAG_START }}arm
build-args: |
GIT_BRANCH=${{ steps.extract_branch.outputs.BRANCH_NAME }}
GIT_REVISION=${{ steps.commit.outputs.hash }}
DATE=${{ steps.current-time.outputs.time }}
- uses: int128/docker-manifest-create-action@v2
with:
tags: ${{ env.TAGS }}
sources: |
totonyus/ydl_api_ng@${{ steps.build_amd.outputs.digest }}
totonyus/ydl_api_ng@${{ steps.build_arm.outputs.digest }}
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3.0.0
if: ${{ env.UPDATE_DOCKER_HUB_DESCRIPTION == 'true' }}
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: totonyus/ydl_api_ng
readme-filepath: ${{ github.workspace }}/readme.md

View File

@ -13,127 +13,23 @@ jobs:
unit_tests:
uses: ./.github/workflows/unit_tests.yml
generate_main_docker_image:
generate_docker_image:
needs: unit_tests
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- id: commit
uses: pr-mpt/actions-commit-hash@v1
- name: Extract branch name
shell: bash
id: extract_branch
run: echo ::set-output name=BRANCH_NAME::${GITHUB_REF#refs/*/}
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: readableTime
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ${{ github.workspace }}
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8
push: true
tags: |
totonyus/ydl_api_ng
- name: Build preview image
uses: ./.github/workflows/build_image.yml
env:
TAG_START: 'preview_'
UPDATE_DOCKER_HUB_DESCRIPTION: 'false'
TAGS: |
totonyus/ydl_api_ng:preview
build-args: |
GIT_BRANCH=${{ steps.extract_branch.outputs.BRANCH_NAME }}
GIT_REVISION=${{ steps.commit.outputs.hash }}
DATE=${{ steps.current-time.outputs.time }}
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3.0.0
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
repository: totonyus/ydl_api_ng
readme-filepath: ${{ github.workspace }}/readme.md
generate_preview_docker_image:
needs: unit_tests
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/develop' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- id: commit
uses: pr-mpt/actions-commit-hash@v1
- name: Extract branch name
shell: bash
id: extract_branch
run: echo ::set-output name=BRANCH_NAME::${GITHUB_REF#refs/*/}
- name: Get current time
uses: josStorer/get-current-time@v2
id: current-time
with:
format: readableTime
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker image (amd64)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
id: build_preview_amd
with:
context: ${{ github.workspace }}
file: dockerfile_amd
platforms: linux/amd64
push: true
tags: totonyus/ydl_api_ng:preview_amd
build-args: |
GIT_BRANCH=${{ steps.extract_branch.outputs.BRANCH_NAME }}
GIT_REVISION=${{ steps.commit.outputs.hash }}
DATE=${{ steps.current-time.outputs.time }}
- name: Build and push Docker image (arm)
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
id: build_preview_arm
with:
context: ${{ github.workspace }}
file: dockerfile_arm
platforms: linux/arm/v7,linux/arm64/v8
push: true
tags: totonyus/ydl_api_ng:preview_arm
build-args: |
GIT_BRANCH=${{ steps.extract_branch.outputs.BRANCH_NAME }}
GIT_REVISION=${{ steps.commit.outputs.hash }}
DATE=${{ steps.current-time.outputs.time }}
- uses: int128/docker-manifest-create-action@v2
with:
tags: totonyus/ydl_api_ng:preview
sources: |
totonyus/ydl_api_ng@${{ steps.build_preview_amd.outputs.digest }}
totonyus/ydl_api_ng@${{ steps.build_preview_arm.outputs.digest }}
- name: Build image
uses: ./.github/workflows/build_image.yml
env:
TAG_START: 'latest_'
UPDATE_DOCKER_HUB_DESCRIPTION: 'false'
TAGS: |
totonyus/ydl_api_ng:latest
totonyus/ydl_api_ng:preview