Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(satp-hermes): add docker deploy actions #3784

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1759,71 +1759,7 @@ jobs:
with:
name: coverage-reports-35
path: ./code-coverage-ts/**/
cactus-plugin-satp-hermes:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-plugin-satp-hermes/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
steps:
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ env.NODEJS_VERSION }}
- uses: actions/checkout@v4.1.1
- id: yarn-cache-dir-path
name: Get yarn cache directory path
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
- id: yarn-cache
name: Restore Yarn Cache
uses: actions/cache@v4.0.1
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: ./.yarn/
restore-keys: |
${{ runner.os }}-yarn-
- run: ./tools/ci.sh
cp-bungee-hermes:
continue-on-error: false
env:
# Otherwise it fails with: You are running out of disk space.
# The runner will stop working when the machine runs out of disk space.
# Free space left: 26 MB
FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-plugin-satp-hermes/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cp-bungee-hermes
JEST_TEST_CODE_COVERAGE_ENABLED: true
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
steps:
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4.0.3
with:
node-version: ${{ env.NODEJS_VERSION }}
- uses: actions/checkout@v4.1.7

- id: yarn-cache
name: Restore Yarn Cache
uses: actions/cache@v4.0.2
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: ./.yarn/
restore-keys: |
${{ runner.os }}-yarn-
- run: ./tools/ci.sh
if: ${{ env.RUN_CODE_COVERAGE == 'true' }}
- name: Upload coverage reports as artifacts
uses: actions/upload-artifact@v4.3.3
with:
name: coverage-reports-36
path: ./code-coverage-ts/**/
cactus-plugin-bungee-hermes:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/satp-hermes-gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: SATP CI - tests and docker deployments
on:
pull_request:
branches: [main, satp-dev]
push:
branches: [main, satp-dev]

jobs:
run-satp-tests:
continue-on-error: false
env:
FULL_BUILD_DISABLED: true
JEST_TEST_PATTERN: packages/cactus-plugin-satp-hermes/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
JEST_TEST_RUNNER_DISABLED: false
TAPE_TEST_RUNNER_DISABLED: true
needs: build-dev
runs-on: ubuntu-22.04
steps:
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4.0.2
with:
node-version: ${{ env.NODEJS_VERSION }}
- uses: actions/checkout@v4.1.1
- id: yarn-cache-dir-path
name: Get yarn cache directory path
run: echo "dir=$(yarn cache dir)" >> "$GITHUB_OUTPUT"
- id: yarn-cache
name: Restore Yarn Cache
uses: actions/cache@v4.0.1
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: ./.yarn/
restore-keys: |
${{ runner.os }}-yarn-
- run: ./tools/ci.sh

set-docker-tags:
runs-on: ubuntu-22.04
needs: run-satp-tests
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/satp-dev')
outputs:
tag_suffix: ${{ steps.set_tags.outputs.tag_suffix }}
tag_version: ${{ steps.set_tags.outputs.tag_version }}
dockerhub_image: ${{ steps.set_tags.outputs.dockerhub_image }}
ghcr_image: ${{ steps.set_tags.outputs.ghcr_image }}
steps:
- uses: actions/checkout@v4.1.7
- name: Set image tags
id: set_tags
run: |
TAG_SUFFIX=$(if [ "${{ github.ref }}" = "refs/heads/main" ]; then echo "prod"; else echo "dev"; fi)
TAG_VERSION="$(date -u +"%Y-%m-%dT%H-%M-%S")-${TAG_SUFFIX}-$(git rev-parse --short HEAD)"
DOCKERHUB_IMAGE="hyperledger/satp-hermes-gateway"
GHCR_IMAGE="ghcr.io/hyperledger-cacti/satp-hermes-gateway"
echo "tag_suffix=${TAG_SUFFIX}" >> $GITHUB_OUTPUT
echo "tag_version=${TAG_VERSION}" >> $GITHUB_OUTPUT
echo "dockerhub_image=${DOCKERHUB_IMAGE}" >> $GITHUB_OUTPUT
echo "ghcr_image=${GHCR_IMAGE}" >> $GITHUB_OUTPUT

build-and-push-dockerhub:
runs-on: ubuntu-22.04
needs: set-docker-tags
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/satp-dev')
steps:
- uses: actions/checkout@v4.1.7
- name: Configure and build bundle
run: |
yarn configure
yarn lerna run build:bundle --scope=@hyperledger/cactus-plugin-satp-hermes
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./packages/cactus-plugin-satp-hermes/
file: ./packages/cactus-plugin-satp-hermes/satp-hermes-gateway.Dockerfile
push: true
labels: |
org.opencontainers.image.source=https://github.com/hyperledger/cacti
org.opencontainers.image.description=SATP Hermes Gateway
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.vendor=Hyperledger
org.opencontainers.image.version=${{ needs.set-docker-tags.outputs.tag_version }}
org.opencontainers.image.visibility=public
tags: |
${{ needs.set-docker-tags.outputs.dockerhub_image }}:${{ needs.set-docker-tags.outputs.tag_version }}
${{ needs.set-docker-tags.outputs.dockerhub_image }}:latest

build-and-push-ghcr:
runs-on: ubuntu-22.04
needs: set-docker-tags
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/satp-dev')
steps:
- uses: actions/checkout@v4.1.7
- name: Configure and build bundle
run: |
yarn configure
yarn lerna run build:bundle --scope=@hyperledger/cactus-plugin-satp-hermes
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./packages/cactus-plugin-satp-hermes/
file: ./packages/cactus-plugin-satp-hermes/satp-hermes-gateway.Dockerfile
push: true
labels: |
org.opencontainers.image.source=https://github.com/hyperledger/cacti
org.opencontainers.image.description=SATP Hermes Gateway
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.vendor=Hyperledger
org.opencontainers.image.version=${{ needs.set-docker-tags.outputs.tag_version }}
org.opencontainers.image.visibility=public
tags: |
${{ needs.set-docker-tags.outputs.ghcr_image }}:${{ needs.set-docker-tags.outputs.tag_version }}
${{ needs.set-docker-tags.outputs.ghcr_image }}:latest
14 changes: 14 additions & 0 deletions packages/cactus-plugin-satp-hermes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,20 @@ docker compose \
--build
```

To push the current version to the official repo, run (tested in MacOS):
```sh
IMAGE_NAME=ghcr.io/hyperledger-cacti/satp-hermes-gateway
DEV_TAG="$(date -u +"%Y-%m-%dT%H-%M-%S")-dev-$(git rev-parse --short HEAD)"

echo "Building Docker image with name: $IMAGE_NAME:$DEV_TAG"

docker build \
--file ./packages/cactus-plugin-satp-hermes/satp-hermes-gateway.Dockerfile \
./packages/cactus-plugin-satp-hermes/ \
--tag $IMAGE_NAME:$DEV_TAG \
--tag $IMAGE_NAME:latest
```

> The `--build` flag is going to save you 99% of the time from docker compose caching your image builds against your will or knowledge during development.

## Contributing
Expand Down
Loading
Loading