From 282b038713fd99bfd12e127b95ec8467f409b0ac Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 26 May 2021 10:41:53 -0700 Subject: [PATCH 01/12] Update push docker container to support container registry Also simplify the existing workflow by replacing shell code with actions --- ci/docker-publish.yml | 69 ++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index ba69744..6152fde 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -2,20 +2,22 @@ name: Docker on: push: - # Publish `$default-branch` as Docker `latest` image. - branches: - - $default-branch - + branches: [ $default-branch ] # Publish `v1.2.3` tags as releases. - tags: - - v* + tags: [ 'v*.*.*' ] + pull_request_target: + branches: [ $default-branch ] # Run tests for any PRs. pull_request: env: - # TODO: Change variable to your image's name. - IMAGE_NAME: image + # TODO: Creates container named ACCOUNT/REPO + # Append /IMAGE-NAME to create a container named ACCOUNT/REPO/IMAGE-NAME + IMAGE_NAME: ${{ github.repository }} + + # Registry. Use docker.io for DockerHub + REGISTRY: ghcr.io jobs: # Run tests. @@ -49,32 +51,31 @@ jobs: packages: write steps: - - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - - name: Build image - run: docker build . --file Dockerfile --tag $IMAGE_NAME + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} - - name: Push image - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - - # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - - # Use Docker `latest` tag convention - [ "$VERSION" == "$default-branch" ] && VERSION=latest - - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + # Don't push on pull requests + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From b574e6db5060fafbf91fafb5c1e2e824fe5e11db Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 26 May 2021 10:55:50 -0700 Subject: [PATCH 02/12] Add notice about third party actions --- ci/docker-publish.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 6152fde..63b02f2 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -1,5 +1,10 @@ name: Docker +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + on: push: branches: [ $default-branch ] From 41a66c656e20c398aa7143b649d3678dae503afc Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 26 May 2021 13:46:54 -0700 Subject: [PATCH 03/12] Use git shas rather than version tags --- ci/docker-publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 63b02f2..26a5f89 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -60,7 +60,7 @@ jobs: uses: actions/checkout@v2 - name: Log into registry ${{ env.REGISTRY }} - uses: docker/login-action@v1 + uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: registry: ${{ env.REGISTRY }} username: ${{ github.repository_owner }} @@ -68,7 +68,7 @@ jobs: - name: Extract Docker metadata id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | @@ -77,7 +77,7 @@ jobs: type=semver,pattern={{version}} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: context: . # Don't push on pull requests From aa30f1448e6f181d695a784d284dbeaefc12a208 Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 26 May 2021 14:07:29 -0700 Subject: [PATCH 04/12] Update ci/docker-publish.yml Co-authored-by: Bryan Clark --- ci/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 26a5f89..d2672ab 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -63,7 +63,7 @@ jobs: uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract Docker metadata From 6fe53a9ebd963520a1da2b470d71380c14c284fb Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 26 May 2021 15:03:41 -0700 Subject: [PATCH 05/12] Remove context configuration since it's already the default --- ci/docker-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 26a5f89..c820f91 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -79,7 +79,6 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: - context: . # Don't push on pull requests push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} From 9317366c912201db28a76971bf16ffcb807f2087 Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 2 Jun 2021 14:21:03 -0700 Subject: [PATCH 06/12] Remove docker tags section to simplify configuration --- ci/docker-publish.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index e676dea..3a5a084 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -71,10 +71,6 @@ jobs: uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc From 9d73235e0373a25865567ea98cba64564503fe68 Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 2 Jun 2021 15:41:23 -0700 Subject: [PATCH 07/12] Remove pull request condition --- ci/docker-publish.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 3a5a084..84c07c5 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -75,7 +75,5 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: - # Don't push on pull requests - push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 7b6d03675b1fac8ce90a9273c862548d5324ab24 Mon Sep 17 00:00:00 2001 From: Sven Pfleiderer Date: Wed, 2 Jun 2021 15:58:44 -0700 Subject: [PATCH 08/12] Revert "Remove pull request condition" This reverts commit 9d73235e0373a25865567ea98cba64564503fe68. --- ci/docker-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 84c07c5..3a5a084 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -75,5 +75,7 @@ jobs: - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: + # Don't push on pull requests + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From aaea7d2c9163c76a095b8c3f483ab92c900bdd65 Mon Sep 17 00:00:00 2001 From: James Curtin Date: Thu, 3 Jun 2021 10:55:41 -0400 Subject: [PATCH 09/12] Update Python package build and upload example (#900) * Update Python package build and upload example * Update python-publish.yml --- ci/python-publish.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ci/python-publish.yml b/ci/python-publish.yml index 1a03a7b..3bfabfc 100644 --- a/ci/python-publish.yml +++ b/ci/python-publish.yml @@ -1,11 +1,16 @@ # This workflow will upload a Python Package using Twine when a release is created # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + name: Upload Python Package on: release: - types: [created] + types: [published] jobs: deploy: @@ -21,11 +26,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} From 4c00e7ffc6203ba2fca6a59e9017a17649bb29a6 Mon Sep 17 00:00:00 2001 From: Tim Etchells Date: Thu, 3 Jun 2021 13:19:02 -0400 Subject: [PATCH 10/12] Replace oc-installer with tools-installer --- ci/openshift.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/openshift.yml b/ci/openshift.yml index 6d5c20a..ec5e0fb 100644 --- a/ci/openshift.yml +++ b/ci/openshift.yml @@ -144,7 +144,8 @@ jobs: # oc-login works on all platforms, but oc must be installed first. # The GitHub Ubuntu runner already includes oc. - # Otherwise, https://github.com/redhat-actions/oc-installer#readme is available. + # Otherwise, https://github.com/redhat-actions/openshift-tools-installer can be used to install oc, + # as well as many other tools. # https://github.com/redhat-actions/oc-login#readme - name: Log in to OpenShift From 0c715d6fe2fb18fcbdeb32a8a8315353b4cf320f Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Thu, 3 Jun 2021 15:07:11 -0400 Subject: [PATCH 11/12] Use $cron-daily for daily schedules (#923) --- .github/workflows/stale.yml | 2 +- automation/stale.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c116b93..b34c768 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,7 +2,7 @@ name: Mark stale issues and pull requests on: schedule: - - cron: "21 4 * * *" + - cron: $cron-daily jobs: stale: diff --git a/automation/stale.yml b/automation/stale.yml index 30c3dd9..277380b 100644 --- a/automation/stale.yml +++ b/automation/stale.yml @@ -2,7 +2,7 @@ name: Mark stale issues and pull requests on: schedule: - - cron: "30 1 * * *" + - cron: $cron-daily jobs: stale: From 90ba42df70b9ef88c62b697b955eb30a46b65732 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Fri, 4 Jun 2021 20:23:02 +0200 Subject: [PATCH 12/12] Simplify Docker publish workflow (#921) Co-authored-by: CrazyMax Co-authored-by: Josh Gross --- ci/docker-publish.yml | 50 ++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/ci/docker-publish.yml b/ci/docker-publish.yml index 3a5a084..ab266ef 100644 --- a/ci/docker-publish.yml +++ b/ci/docker-publish.yml @@ -6,51 +6,26 @@ name: Docker # documentation. on: + schedule: + - cron: $cron-daily push: branches: [ $default-branch ] - # Publish `v1.2.3` tags as releases. + # Publish semver tags as releases. tags: [ 'v*.*.*' ] - pull_request_target: - branches: [ $default-branch ] - - # Run tests for any PRs. pull_request: + branches: [ $default-branch ] env: - # TODO: Creates container named ACCOUNT/REPO - # Append /IMAGE-NAME to create a container named ACCOUNT/REPO/IMAGE-NAME + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / IMAGE_NAME: ${{ github.repository }} - # Registry. Use docker.io for DockerHub - REGISTRY: ghcr.io jobs: - # Run tests. - # See also https://docs.docker.com/docker-hub/builds/automated-testing/ - test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Run tests - run: | - if [ -f docker-compose.test.yml ]; then - docker-compose --file docker-compose.test.yml build - docker-compose --file docker-compose.test.yml run sut - else - docker build . --file Dockerfile - fi - - # Push image to GitHub Packages. - # See also https://docs.docker.com/docker-hub/builds/ - push: - # Ensure test job passes before pushing image. - needs: test + build: runs-on: ubuntu-latest - if: github.event_name == 'push' - permissions: contents: read packages: write @@ -59,23 +34,30 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 + # Login against a Docker registry except on PR + # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action - name: Build and push Docker image uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc with: - # Don't push on pull requests + context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}