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

chore: improve docker release pipeline #675

Merged
merged 12 commits into from
Dec 18, 2023
55 changes: 38 additions & 17 deletions .github/workflows/release-docker.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
name: Release Docker Image
on:
on:
release:
types:
types:
- published

jobs:

publish-docker:
name: Generating Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get version without v character
id: version
run: |
VERSION=${{github.event.release.tag_name}}
VERSION=${{ github.event.release.tag_name }}
VERSION_WITHOUT_V=${VERSION:1}
echo "value=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT

- name: Release to Docker
run: |
echo ${{secrets.DOCKER_PASSWORD}} | docker login -u ${{secrets.DOCKER_USERNAME}} --password-stdin
npm run docker:build
docker tag asyncapi/cli:latest asyncapi/cli:${{ steps.version.outputs.value }}
docker push asyncapi/cli:${{ steps.version.outputs.value }}
docker push asyncapi/cli:latest

- name : Sync README.md and Description to Docker Hub
uses: actions/checkout@master

- name: Set Up QEMU
uses: docker/setup-qemu-action@v2

- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# This workflow triggers on GitHub Release, but it may start before the npm package is published.
- name: Sleep for 30 sec
run: sleep 30s

- name: Build Image
uses: docker/build-push-action@v4
with:
push: true
load: false
build-args: |
ASYNCAPI_CLI_VERSION=${{ steps.version.outputs.value }}
tags: |
asyncapi/cli:${{ steps.version.outputs.value }}
asyncapi/cli:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha

- name: Sync README.md and Description to Docker Hub
uses: actions/[email protected]

- uses: meeDamian/[email protected]
derberg marked this conversation as resolved.
Show resolved Hide resolved
with:
user: ${{secrets.DOCKER_USERNAME}}
user: ${{ secrets.DOCKER_USERNAME }}
pass: ${{ secrets.DOCKER_PASSWORD }}
slug: asyncapi/cli
description: CLI to work with your AsyncAPI files
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:16-alpine

ARG ASYNCAPI_CLI_VERSION=0.59.1

# Create a non-root user
RUN addgroup -S myuser && adduser -S myuser -G myuser

Expand All @@ -16,9 +18,9 @@ RUN apk --update add git chromium && \
rm /var/cache/apk/*

# Installing latest released npm package
RUN npm install --ignore-scripts -g @asyncapi/cli
RUN npm install --ignore-scripts -g @asyncapi/cli@"$ASYNCAPI_CLI_VERSION"

# Switch to the non-root user
USER myuser

ENTRYPOINT [ "asyncapi" ]
ENTRYPOINT [ "asyncapi" ]