Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
WIP Simplify constants for workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jacque006 committed Jun 10, 2021
1 parent 29a0a5a commit 016f456
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 41 deletions.
35 changes: 12 additions & 23 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,14 @@ on:
release:
types: [published]

jobs:
images:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: thehubbleproject/node
DOCKER_IMAGE_SHA: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
DOCKER_IMAGE_TAG: ${{ env.DOCKER_IMAGE }}:${{ github.event.release.tag_name }}
DOCKER_IMAGE_LATEST: ${{ env.DOCKER_IMAGE }}:latest

outputs:
base: ${{ steps.base.outputs.image }}
sha: ${{ steps.sha.outputs.image }}
tag: ${{ steps.tag.outputs.image }}
latest: ${{ steps.latest.outputs.image }}
steps:
- id: base
run: echo "::set-output name=image::thehubbleproject/node"
- id: sha
run: echo "::set-output name=image::thehubbleproject/node:${{ github.sha }}"
- id: tag
run: echo "::set-output name=image::thehubbleproject/node:${{ github.event.release.tag_name }}"
- id: latest
run: echo "::set-output name=image::thehubbleproject/node:latest"

docker:
jobs:
pull-tag-push:
runs-on: ubuntu-latest
needs: images

Expand All @@ -37,14 +25,15 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Pull image for git sha
run: docker pull ${{needs.images.outputs.sha}}
run: docker pull ${{ env.DOCKER_IMAGE_SHA }}
-
name: Tag image with release
run: docker tag ${{needs.images.outputs.sha}} ${{needs.images.outputs.tag}}
run: docker tag ${{ env.DOCKER_IMAGE_SHA }} ${{ env.DOCKER_IMAGE_TAG }}
-
name: Tag image with latest
if: ${{ github.event.release.prerelease == 'false' }}
run: docker tag ${{needs.images.outputs.sha}} ${{needs.images.outputs.latest}}
run: docker tag ${{ env.DOCKER_IMAGE_SHA }} ${{ env.DOCKER_IMAGE_LATEST }}
-
name: Push tagged image(s)
run: docker push ${{needs.images.outputs.base}}
# Pushing the image name without a tag will push all new tags.
run: docker push ${{ env.DOCKER_IMAGE }}
9 changes: 6 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ on:
pull_request:
branches: [ master ]

env:
DOCKER_IMAGE: thehubbleproject/node

jobs:
docker:
build-push:
runs-on: ubuntu-latest
steps:
-
Expand All @@ -29,11 +32,11 @@ jobs:
with:
file: docker/Dockerfile
push: true
tags: thehubbleproject/node:${{ github.sha }}
tags: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
# Consider using GitHub local cache in the future
# https://docs.docker.com/ci-cd/github-actions/#optimizing-the-workflow
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
cache-from: type=registry,ref=thehubbleproject/node:latest
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:latest
cache-to: type=inline
-
name: Image digest
Expand Down
21 changes: 6 additions & 15 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,19 @@ on:
pull_request:
branches: [ master ]

jobs:
nodejs:
runs-on: ubuntu-latest

outputs:
version: ${{ steps.nodejs.outputs.version }}
steps:
- id: nodejs
run: echo "::set-output name=version::10.x"
env:
NODEJS_VERSION: 10.x

jobs:
lint-bench:
runs-on: ubuntu-latest
needs: nodejs

steps:
- uses: actions/checkout@v2
-
uses: actions/setup-node@v2
with:
node-version: ${{needs.nodejs.outputs.version}}
node-version: ${{ env.NODEJS_VERSION }}
- run: npm ci

- run: npm run lint
Expand All @@ -46,14 +39,13 @@ jobs:

test-fast-client:
runs-on: ubuntu-latest
needs: nodejs

steps:
- uses: actions/checkout@v2
-
uses: actions/setup-node@v2
with:
node-version: ${{needs.nodejs.outputs.version}}
node-version: ${{ env.NODEJS_VERSION }}
- run: npm ci

- run: npm run generate
Expand All @@ -62,14 +54,13 @@ jobs:

test-slow-integration:
runs-on: ubuntu-latest
needs: nodejs

steps:
- uses: actions/checkout@v2
-
uses: actions/setup-node@v2
with:
node-version: ${{needs.nodejs.outputs.version}}
node-version: ${{ env.NODEJS_VERSION }}
- run: npm ci

- run: npm run generate
Expand Down

0 comments on commit 016f456

Please sign in to comment.