Deploy #50
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: Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
job: | |
description: Job to run | |
required: true | |
type: choice | |
options: | |
- cli | |
default: cli | |
semver: | |
description: Bump version | |
required: true | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
default: patch | |
build-docker: | |
description: Release companion Docker and Action Docker images | |
type: boolean | |
default: true | |
jobs: | |
deploy-cli: | |
if: ${{ github.event.inputs.job == 'cli' }} | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{steps.version-out.outputs.version}} | |
env: | |
DIR: apps/cli | |
steps: | |
- uses: actions/[email protected] | |
with: | |
token: '${{ secrets.PERSONAL_ACCESS_TOKEN }}' | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install deps | |
run: cd ${{env.DIR}} && npm install | |
- name: Run test | |
run: cd ${{env.DIR}} && npm run test | |
- name: Compile | |
run: cd ${{env.DIR}} && npm run build | |
- name: Bump version | |
run: cd ${{env.DIR}} && npm version ${{github.event.inputs.semver}} | |
- name: NPM Publish | |
id: publish | |
uses: JS-DevTools/[email protected] | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: ${{env.DIR}} | |
ignore-scripts: false | |
- name: Export version to Docker jobs | |
id: version-out | |
run: echo "version=${{steps.publish.outputs.version}}" >> $GITHUB_OUTPUT | |
- name: Commit package.json changes | |
uses: EndBug/[email protected] | |
with: | |
author_name: Sokari | |
author_email: [email protected] | |
message: "Release CLI version ${{ steps.publish.outputs.version }}" | |
add: '${{ env.DIR }}/*.json' | |
push: 'origin main --force' | |
tag: 'v${{steps.publish.outputs.version}} --force' | |
deploy-docker-action: | |
if: ${{ github.event.inputs.job == 'cli' && github.event.inputs.build-docker }} | |
runs-on: ubuntu-latest | |
needs: deploy-cli | |
env: | |
DIR: apps/action | |
steps: | |
- uses: actions/[email protected] | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
context: ${{env.DIR}} | |
file: ${{env.DIR}}/action.Dockerfile | |
platforms: linux/amd64 | |
push: true | |
build-args: CLI_VERSION=${{needs.deploy-cli.outputs.version}} | |
tags: | | |
sokari/allure-deployer-action:${{needs.deploy-cli.outputs.version}} | |
sokari/allure-deployer-action:${{ github.sha }} | |
deploy-docker: | |
if: ${{ github.event.inputs.job == 'cli' && github.event.inputs.build-docker }} | |
runs-on: ubuntu-latest | |
needs: deploy-cli | |
env: | |
DIR: apps/docker | |
steps: | |
- uses: actions/[email protected] | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64,amd64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
context: ${{env.DIR}} | |
file: ${{env.DIR}}/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
build-args: CLI_VERSION=${{needs.deploy-cli.outputs.version}} | |
tags: | | |
sokari/allure-deployer:latest | |
sokari/allure-deployer:${{ github.sha }} | |
sokari/allure-deployer:${{needs.deploy-cli.outputs.version}} |