From 24ea20cb1bd95640298c4cfb7c89ee7d71b4a93b Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 11:21:47 +0200 Subject: [PATCH 1/7] Create main.yml --- .github/workflows/main.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..3e0d6415b6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,22 @@ +name: Publish Docker image +on: + release: + types: [published] +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Push to GitHub Packages + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: docker.pkg.github.com + repository: rkallenkoot/redoc/cli + tag_with_ref: true From 078ccce355e63571ed6dcc2a917dfc7fb3fb85b4 Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 11:40:26 +0200 Subject: [PATCH 2/7] Upgrade to docker/build-push-action@v2 --- .github/workflows/main.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e0d6415b6..5412c1e1a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,11 +12,27 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v2 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=myorg/myrepository + VERSION=edge + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + elif [[ $GITHUB_REF == refs/pull/* ]]; then + VERSION=pr-${{ github.event.number }} + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [ "${{ github.event_name }}" = "push" ]; then + TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" + fi + echo ::set-output name=version::${VERSION} + echo ::set-output name=tags::${TAGS} + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - name: Push to GitHub Packages - uses: docker/build-push-action@v1 + uses: docker/build-push-action@v2 with: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - registry: docker.pkg.github.com - repository: rkallenkoot/redoc/cli - tag_with_ref: true + context: ./cli + tags: ${{ steps.prep.outputs.tags }} From cfd5761168ff5545e74befbbdfa0438b853701c7 Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 12:03:13 +0200 Subject: [PATCH 3/7] Use ghcr.io --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5412c1e1a3..b9f5ab0ed5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=myorg/myrepository + DOCKER_IMAGE=ghcr.io/Rkallenkoot/redoc/cli VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} From 1804c10786b4d46816c49163d8d9ebec2a89c99f Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 12:04:24 +0200 Subject: [PATCH 4/7] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9f5ab0ed5..143c02b42a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=ghcr.io/Rkallenkoot/redoc/cli + DOCKER_IMAGE=ghcr.io/rkallenkoot/redoc/cli VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/} From 313ef319b807527d8b810cac010f81f5ea202bfa Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 12:08:59 +0200 Subject: [PATCH 5/7] Update main.yml --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 143c02b42a..d05482a785 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,4 +35,5 @@ jobs: uses: docker/build-push-action@v2 with: context: ./cli + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} From 1d93ddd904749a27b3d3538174a40372e281ffc0 Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 12:14:43 +0200 Subject: [PATCH 6/7] Update main.yml --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d05482a785..661f1f1a52 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,6 +12,12 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Prepare id: prep run: | From d9f15b70bc36d85beb5b1858d273db449947b222 Mon Sep 17 00:00:00 2001 From: Roelof Kallenkoot Date: Tue, 11 May 2021 12:16:45 +0200 Subject: [PATCH 7/7] Update DOCKER_IMAGE to redocly --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 661f1f1a52..42afcc4c9d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,7 @@ jobs: - name: Prepare id: prep run: | - DOCKER_IMAGE=ghcr.io/rkallenkoot/redoc/cli + DOCKER_IMAGE=ghcr.io/redocly/redoc/cli VERSION=edge if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/}