From 2c88aa3acd3f62e548262cdfb8d38f8f114b43af Mon Sep 17 00:00:00 2001 From: Xavier Serrat Bordas Date: Wed, 4 Jan 2023 00:12:51 +0100 Subject: [PATCH 1/2] [#21] Add build-image.yaml workflow to build docker images on push --- .github/workflows/build-image.yaml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/build-image.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..a7ba628 --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,44 @@ +name: ci + +on: + push: + branches: + - 'issue#21-gh-action' + +jobs: + Build-Docker-Image: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + platforms: linux/amd64,linux/arm64 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Replace char '#' to '_' from GITHUB_REF_NAME env variable + id: github_ref_name_replacement_step + uses: frabert/replace-string-action@v2.0 + with: + pattern: '#' + string: ${{ github.ref_name }} + replace-with: '_' + - + name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: xserrat/facebook-demucs:${{ steps.github_ref_name_replacement_step.outputs.replaced }} \ No newline at end of file From d667788030f6e8457f8ebec43445d0757f68a6f3 Mon Sep 17 00:00:00 2001 From: Xavier Serrat Bordas Date: Wed, 4 Jan 2023 00:59:53 +0100 Subject: [PATCH 2/2] [#21] Use docker/metadata-action Github Action to customize docker tags based on the current branch --- .github/workflows/build-image.yaml | 31 +++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml index a7ba628..4d97176 100644 --- a/.github/workflows/build-image.yaml +++ b/.github/workflows/build-image.yaml @@ -20,20 +20,32 @@ jobs: uses: docker/setup-buildx-action@v2 with: platforms: linux/amd64,linux/arm64 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + xserrat/facebook-demucs + tags: | + # set branch as tag name + type=ref,event=push,value={{branch}} + # set latest tag for default branch + type=raw,value=latest,enable={{is_default_branch}} - name: Login to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Replace char '#' to '_' from GITHUB_REF_NAME env variable - id: github_ref_name_replacement_step - uses: frabert/replace-string-action@v2.0 - with: - pattern: '#' - string: ${{ github.ref_name }} - replace-with: '_' +# - +# name: Replace char '#' to '_' from GITHUB_REF_NAME env variable +# id: github_ref_name_replacement_step +# uses: frabert/replace-string-action@v2.0 +# with: +# pattern: '#' +# string: ${{ github.ref_name }} +# replace-with: '_' - name: Build and push uses: docker/build-push-action@v3 @@ -41,4 +53,5 @@ jobs: context: . push: true platforms: linux/amd64,linux/arm64 - tags: xserrat/facebook-demucs:${{ steps.github_ref_name_replacement_step.outputs.replaced }} \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} +# tags: xserrat/facebook-demucs:${{ steps.github_ref_name_replacement_step.outputs.replaced }} \ No newline at end of file