From caee9cfeb3dea586e28d7fbabf0f40becc1243e6 Mon Sep 17 00:00:00 2001 From: Til Blechschmidt Date: Sat, 6 Mar 2021 10:31:20 +0100 Subject: [PATCH] :construction_worker: Update GitHub Actions to latest versions --- .github/workflows/release.yml | 124 ++++++++++++++++++++++++++++------ 1 file changed, 104 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 081dcaf0..fd4d3af5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -64,15 +64,43 @@ jobs: name: api-executable path: .artifacts/api-executable - - name: Build and push webgrid/api Docker image - uses: docker/build-push-action@v1 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=webgrid/api + 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 "version=${VERSION}" >> $GITHUB_ENV + echo "tags=${TAGS}" >> $GITHUB_ENV + echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + + - name: Login to DockerHub + uses: docker/login-action@v1 with: - dockerfile: distribution/docker/images/api/Dockerfile username: webgrid password: ${{ secrets.DOCKER_HUB_TOKEN }} - repository: webgrid/api - tag_with_ref: true - push: ${{ startsWith(github.ref, 'refs/tags/') }} + + - name: Build and push webgrid/api Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: distribution/docker/images/api/Dockerfile + tags: ${{ env.tags }} + push: ${{ github.event_name != 'pull_request' }} + labels: | + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.created=${{ env.created }} + org.opencontainers.image.revision=${{ github.sha }} publish-core: name: 🐳 Publish Core to Docker Hub @@ -86,15 +114,43 @@ jobs: name: core-executable path: .artifacts/core-executable - - name: Build and push webgrid/core Docker image - uses: docker/build-push-action@v1 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=webgrid/core + 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 "version=${VERSION}" >> $GITHUB_ENV + echo "tags=${TAGS}" >> $GITHUB_ENV + echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + + - name: Login to DockerHub + uses: docker/login-action@v1 with: - dockerfile: distribution/docker/images/core/Dockerfile username: webgrid password: ${{ secrets.DOCKER_HUB_TOKEN }} - repository: webgrid/core - tag_with_ref: true - push: ${{ startsWith(github.ref, 'refs/tags/') }} + + - name: Build and push webgrid/core Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: distribution/docker/images/core/Dockerfile + tags: ${{ env.tags }} + push: ${{ github.event_name != 'pull_request' }} + labels: | + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.created=${{ env.created }} + org.opencontainers.image.revision=${{ github.sha }} publish-node: name: 🐳 Publish Node to Docker Hub @@ -111,16 +167,44 @@ jobs: name: core-executable path: .artifacts/core-executable - - name: Build and push webgrid/node-${{ matrix.browser }} Docker image - uses: docker/build-push-action@v1 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=webgrid/node-${{ matrix.browser }} + 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 "version=${VERSION}" >> $GITHUB_ENV + echo "tags=${TAGS}" >> $GITHUB_ENV + echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + + - name: Login to DockerHub + uses: docker/login-action@v1 with: - dockerfile: distribution/docker/images/node/Dockerfile - build_args: browser=${{ matrix.browser }} username: webgrid password: ${{ secrets.DOCKER_HUB_TOKEN }} - repository: webgrid/node-${{ matrix.browser }} - tag_with_ref: true - push: ${{ startsWith(github.ref, 'refs/tags/') }} + + - name: Build and push webgrid/node-${{ matrix.browser }} Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: distribution/docker/images/node/Dockerfile + build-args: browser=${{ matrix.browser }} + tags: ${{ env.tags }} + push: ${{ github.event_name != 'pull_request' }} + labels: | + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.created=${{ env.created }} + org.opencontainers.image.revision=${{ github.sha }} publish-docs: name: 📚 Publish Docs to GitHub Pages @@ -186,7 +270,7 @@ jobs: RELEASE_ASSET_UPLOAD_URL="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" echo "$RELEASE_ASSET_UPLOAD_URL" - echo "::set-env name=RELEASE_ASSET_UPLOAD_URL::$RELEASE_ASSET_UPLOAD_URL" + echo "RELEASE_ASSET_UPLOAD_URL=$RELEASE_ASSET_UPLOAD_URL" >> $GITHUB_ENV - name: Attach Core executable uses: actions/upload-release-asset@v1