From c9f4f22423d32cbce7980c3c522409310e4e838d Mon Sep 17 00:00:00 2001 From: Yordis Prieto Lazo Date: Wed, 11 Nov 2020 22:43:08 -0500 Subject: [PATCH 1/2] add github docker registry integration --- .../workflows/publish-to-github-registry.yml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/publish-to-github-registry.yml diff --git a/.github/workflows/publish-to-github-registry.yml b/.github/workflows/publish-to-github-registry.yml new file mode 100644 index 000000000..10e8319e6 --- /dev/null +++ b/.github/workflows/publish-to-github-registry.yml @@ -0,0 +1,78 @@ +name: Publish to GitHub Registry + +on: + push: + branches: + - master + paths: + - "**/Dockerfile" + - "**/docker-entrypoint.sh" + - genMatrix.js + - .github/workflows/publish-to-github-registry.yml + +jobs: + gen_matrix: + name: Generate matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.generator.outputs.result }} + steps: + - name: Calculate file differences + uses: lots0logs/gh-action-get-changed-files@2.1.4 + id: diff + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout + uses: actions/checkout@v2 + + - name: Generate testing matrix + uses: actions/github-script@v3 + id: generator + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const script = require(`${process.env.GITHUB_WORKSPACE}/genMatrix.js`) + return script( + ${{ steps.diff.outputs.added }}, + ${{ steps.diff.outputs.modified }}, + ${{ steps.diff.outputs.renamed }}, + ); + + publish: + name: Push Image + if: ${{ fromJson(needs.gen_matrix.outputs.matrix) }} + needs: gen_matrix + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.gen_matrix.outputs.matrix) }} + steps: + - name: Setup builder + uses: docker/setup-buildx-action@v1 + + - name: Login to Github Docker Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CR_PAT }} + + - name: Get short Node version + uses: actions/github-script@v3 + id: short-version + with: + result-encoding: string + script: return "${{ matrix.version }}".split('.')[0] + + - name: Checkout + uses: actions/checkout@v2 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + push: true + context: . + file: ./${{ steps.short-version.outputs.result }}/${{ matrix.variant }}/Dockerfile + tags: | + ghcr.io/${{ github.repository }}/node:${{ matrix.version }}-${{ matrix.variant }} From d0adc1114d03480d0e2d082646e9aeba94ce4c6c Mon Sep 17 00:00:00 2001 From: Yordis Prieto Date: Wed, 24 Mar 2021 18:39:19 -0700 Subject: [PATCH 2/2] fix PAT token --- .github/workflows/publish-to-github-registry.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-github-registry.yml b/.github/workflows/publish-to-github-registry.yml index 10e8319e6..cdfaeff2d 100644 --- a/.github/workflows/publish-to-github-registry.yml +++ b/.github/workflows/publish-to-github-registry.yml @@ -56,7 +56,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.CR_PAT }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Get short Node version uses: actions/github-script@v3