Skip to content

Commit 8220e62

Browse files
authored
Create main.yml
1 parent 107ae23 commit 8220e62

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/workflows/main.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ "master", "develop" ]
9+
pull_request:
10+
branches: [ "master", "develop" ]
11+
workflow_dispatch:
12+
13+
env:
14+
# Use docker.io for Docker Hub if empty
15+
REGISTRY: ghcr.io
16+
# github.repository as <account>/<repo>
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
jobs:
20+
21+
publish:
22+
runs-on: ubuntu-latest
23+
if: github.event_name != 'pull_request'
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
# Install the cosign tool except on PR
28+
# https://github.com/sigstore/cosign-installer
29+
- name: Install cosign
30+
if: github.event_name != 'pull_request'
31+
uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25
32+
with:
33+
cosign-release: 'v1.9.0'
34+
35+
# Workaround: https://github.com/docker/build-push-action/issues/461
36+
- name: Setup Docker buildx
37+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
38+
39+
# Login against a Docker registry except on PR
40+
# https://github.com/docker/login-action
41+
- name: Log into registry ${{ env.REGISTRY }}
42+
if: github.event_name != 'pull_request'
43+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
44+
with:
45+
registry: ${{ env.REGISTRY }}
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
# Extract metadata (tags, labels) for Docker
50+
# https://github.com/docker/metadata-action
51+
- name: Extract Docker metadata
52+
id: meta
53+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
54+
with:
55+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
56+
57+
58+
- name: Use cached build output
59+
uses: actions/cache@v2
60+
env:
61+
cache-name: cache-dist
62+
with:
63+
path: dist/
64+
key: ${{ runner.os }}-${{ github.run_id }}
65+
66+
# Build and push Docker image with Buildx (don't push on PR)
67+
# https://github.com/docker/build-push-action
68+
- name: Build and push Docker image
69+
id: build-and-push
70+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
71+
with:
72+
context: .
73+
push: ${{ github.event_name != 'pull_request' }}
74+
tags: ${{ steps.meta.outputs.tags }}
75+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)