Skip to content

Commit

Permalink
chore: improve docker release pipeline (#675)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Gornicki <[email protected]>
  • Loading branch information
Ferror and derberg authored Dec 18, 2023
1 parent a096ae6 commit df5f1a6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
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]
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" ]

0 comments on commit df5f1a6

Please sign in to comment.