From 158229bb5136ac8ed4517ea30ba5c31dd1a4241b Mon Sep 17 00:00:00 2001 From: Totonyus Date: Fri, 24 May 2024 20:12:01 +0200 Subject: [PATCH] Split latest and preview in two files --- .github/workflows/docker-image.yml | 38 --------- .github/workflows/docker-image_preview.yml | 85 +++++++++++++++++++ ...ild_image.yml => docker-image_release.yml} | 33 ++++--- 3 files changed, 105 insertions(+), 51 deletions(-) delete mode 100644 .github/workflows/docker-image.yml create mode 100644 .github/workflows/docker-image_preview.yml rename .github/workflows/{build_image.yml => docker-image_release.yml} (79%) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index d4633db..0000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Build docker image - -on: - push: - branches: - - main - - develop - paths-ignore: - - '**.md' - - 'docker-compose*' - -jobs: - unit_tests: - uses: ./.github/workflows/unit_tests.yml - - generate_docker_image: - needs: unit_tests - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - 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 - - - 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 \ No newline at end of file diff --git a/.github/workflows/docker-image_preview.yml b/.github/workflows/docker-image_preview.yml new file mode 100644 index 0000000..ce919ec --- /dev/null +++ b/.github/workflows/docker-image_preview.yml @@ -0,0 +1,85 @@ +name: Build docker image + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + - 'docker-compose*' + +jobs: + unit_tests: + uses: ./.github/workflows/unit_tests.yml + + generate_main_docker_image: + needs: unit_tests + 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 docker image (amd) + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + id: build_amd + with: + context: ${{ github.workspace }} + platforms: linux/amd64 + push: true + tags: | + totonyus/ydl_api_ng:latest_amd + 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 docker image (arm) + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + id: build_arm + with: + context: ${{ github.workspace }} + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 + push: true + tags: | + totonyus/ydl_api_ng:latest_arm + 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:latest + totonyus/ydl_api_ng:preview + sources: | + totonyus/ydl_api_ng@${{ steps.build_amd.outputs.digest }} + totonyus/ydl_api_ng@${{ steps.build_arm.outputs.digest }} diff --git a/.github/workflows/build_image.yml b/.github/workflows/docker-image_release.yml similarity index 79% rename from .github/workflows/build_image.yml rename to .github/workflows/docker-image_release.yml index 340e764..efc0411 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/docker-image_release.yml @@ -1,12 +1,19 @@ -name: Build single image +name: Build docker image on: push: - branches-ignore: - - '**' + branches: + - develop + paths-ignore: + - '**.md' + - 'docker-compose*' jobs: - generate_docker_image: + unit_tests: + uses: ./.github/workflows/unit_tests.yml + + generate_main_docker_image: + needs: unit_tests runs-on: ubuntu-latest steps: - name: Checkout code @@ -38,29 +45,29 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build and push Docker image (amd) + - name: Build 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 + 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) + - name: Build 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 + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 push: true - tags: totonyus/ydl_api_ng:${{ env.TAG_START }}arm + tags: | + totonyus/ydl_api_ng:preview_arm build-args: | GIT_BRANCH=${{ steps.extract_branch.outputs.BRANCH_NAME }} GIT_REVISION=${{ steps.commit.outputs.hash }} @@ -68,14 +75,14 @@ jobs: - uses: int128/docker-manifest-create-action@v2 with: - tags: ${{ env.TAGS }} + tags: | + totonyus/ydl_api_ng:preview 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 }}