Added credits, fixed styling #6
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: Build and Publish Docker Image | |
on: | |
push: | |
branches: | |
- main | |
- development | |
tags: | |
- v* | |
- rc-* | |
pull_request: | |
branches: | |
- main | |
- development | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
lowercase: ${{ steps.lowercase.outputs.LOWERCASE }} | |
is_pr: ${{ steps.pr.outputs.IS_PR }} | |
tag_name: ${{ steps.tag.outputs.TAG_NAME }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Convert repository owner to lowercase | |
id: lowercase | |
run: echo "LOWERCASE=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')" >> $GITHUB_OUTPUT | |
- name: Check if currently in a pull request | |
id: pr | |
run: echo "IS_PR=$(test -n "${{ github.event.pull_request }}" && echo "true" || echo "false")" >> $GITHUB_OUTPUT | |
- name: Create the tag name | |
id: tag | |
run: | | |
if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
echo "TAG_NAME=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> $GITHUB_OUTPUT | |
elif [[ "${{ github.ref_name }}" == "main" ]]; then | |
echo "TAG_NAME=latest" >> $GITHUB_OUTPUT | |
else | |
if [[ "${{ steps.pr.outputs.IS_PR }}" == "true" ]]; then | |
echo "TAG_NAME=pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
else | |
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
fi | |
fi | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: Run eslint | |
run: npm run lint | |
# test: | |
# runs-on: ubuntu-latest | |
# env: | |
# LONG_LIVED_TOKENS_ENABLED: true | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v4 | |
# - name: Install node | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version-file: .nvmrc | |
# cache: "npm" | |
# - name: Install dependencies | |
# run: npm ci | |
# - name: Run tests | |
# run: npm run test | |
build-and-push: | |
runs-on: ubuntu-latest | |
needs: [setup, lint] | |
if: ${{ needs.setup.outputs.is_pr == 'false' }} | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: | | |
${{ needs.setup.outputs.lowercase }}/vnc-viewer:${{ needs.setup.outputs.tag_name }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |