Merge pull request #32 from skriptfabrik/dependabot/npm_and_yarn/stop… #59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
env: | |
DOCKER_BUILDKIT: 1 | |
DOCKER_BUILDKIT_INLINE_CACHE: 1 | |
DOCKER_IMAGE_NAME: skriptfabrik/elements-cli | |
jobs: | |
publish-push: | |
name: Publish package and Push Docker images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Node.js version ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install dependencies | |
run: |- | |
npm ci | |
- name: Export short SHA | |
run: |- | |
echo "GITHUB_SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-8)" >> ${GITHUB_ENV} | |
- name: Set package version | |
if: github.ref_name == 'main' | |
run: |- | |
PACKAGE_VERSION=$(jq -r .version package.json) | |
npm version "${PACKAGE_VERSION%-*}-${GITHUB_SHORT_SHA}" --no-git-tag-version | |
- name: Set package version from Git | |
if: github.ref_type == 'tag' | |
run: |- | |
npm version from-git --no-git-tag-version | |
- name: Publish package | |
uses: JS-DevTools/npm-publish@v2 | |
if: github.ref_type == 'tag' | |
with: | |
access: public | |
token: ${{ secrets.NPM_TOKEN }} | |
- name: Log in to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and Push latest Docker image | |
if: github.ref_name == 'main' | |
uses: docker/build-push-action@v4 | |
with: | |
build-args: |- | |
BUILDKIT_INLINE_CACHE=${{ env.DOCKER_BUILDKIT_INLINE_CACHE }} | |
ELEMENTS_CLI_VERSION=${{ env.GITHUB_SHORT_SHA }} | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_NAME }}:latest | |
context: . | |
platforms: |- | |
linux/amd64 | |
linux/arm64 | |
pull: true | |
push: true | |
tags: |- | |
${{ env.DOCKER_IMAGE_NAME }}:latest | |
- name: Export release version | |
if: github.ref_type == 'tag' | |
run: |- | |
echo "RELEASE_VERSION=${GITHUB_REF_NAME}" >> ${GITHUB_ENV} | |
- name: Build and Push Docker image release version | |
if: github.ref_type == 'tag' | |
uses: docker/build-push-action@v4 | |
with: | |
build-args: |- | |
BUILDKIT_INLINE_CACHE=${{ env.DOCKER_BUILDKIT_INLINE_CACHE }} | |
ELEMENTS_CLI_VERSION=v${{ env.RELEASE_VERSION }} | |
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE_NAME }}:latest | |
context: . | |
platforms: |- | |
linux/amd64 | |
linux/arm64 | |
pull: true | |
push: true | |
tags: |- | |
${{ env.DOCKER_IMAGE_NAME }}:${{ env.RELEASE_VERSION }} |