Merge pull request #95 from tv2/SOF-1770/register-publish-image-workflow #298
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: Node CI | |
on: | |
push: | |
branches: | |
- "**" | |
tags: | |
- "**" | |
workflow_dispatch: | |
jobs: | |
run-yarn-build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
- uses: actions/cache@v2 | |
with: | |
path: "**/node_modules" | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: yarn install | |
run: yarn install --check-files --frozen-lockfile | |
- name: yarn validate:dependencies | |
run: yarn validate:dependencies | |
continue-on-error: true | |
- name: yarn unit test | |
run: yarn unit | |
- name: yarn build | |
run: yarn build | |
- uses: actions/upload-artifact@main | |
with: | |
name: dist artifacts | |
path: dist | |
dockerhub-release-master: | |
runs-on: ubuntu-latest | |
needs: [run-yarn-build] | |
if: | | |
((github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop') || | |
startsWith(github.ref, 'refs/tags/v')) && | |
github.event_name != 'pull_request' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v2 | |
with: | |
name: dist artifacts | |
path: dist | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: "tv2media/${{ github.event.repository.name }}" | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push docker image tags | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
dockerhub-release-custom-tag: | |
runs-on: ubuntu-latest | |
needs: [run-yarn-build] | |
if: | | |
startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref, 'refs/tags/v') | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v2 | |
with: | |
name: dist artifacts | |
path: dist | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: "tv2media/${{ github.event.repository.name }}" | |
tags: | | |
type=ref,event=tag | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push docker image tags | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |