-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added dev github actions workflow
- Loading branch information
1 parent
b035347
commit 1c1454b
Showing
7 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
####################################################################################################################### | ||
# NOTE: DOES NOT WORK YET | ||
####################################################################################################################### | ||
|
||
name: 'Branch exists' | ||
description: 'Check that branch exists' | ||
inputs: | ||
branch: | ||
description: 'branch to check existence for' | ||
required: true | ||
outputs: | ||
exists: | ||
description: "Boolean of whether branch exists" | ||
value: ${{ steps.branch.outputs.exists }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check branch | ||
id: branch | ||
env: | ||
branch: ${{ inputs.branch }} | ||
shell: bash | ||
run: | | ||
if [ -z $(git show-ref -- heads/$branch) ]; then | ||
echo ::set-output name=exists::false | ||
else | ||
echo ::set-output name=exists::true | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "Cache dependencies" | ||
description: "Cache dependencies" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Cache dependencies | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ env.node-version }} | ||
cache: ${{ env.node-package-manager }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: 'Check secret' | ||
description: 'Check secret' | ||
inputs: | ||
secret: | ||
description: 'Secret to check' | ||
required: true | ||
outputs: | ||
defined: | ||
description: "Boolean of whether secret is defined" | ||
value: ${{ steps.secret.outputs.defined }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check secrets | ||
id: secret | ||
env: | ||
secret: ${{ inputs.secret }} | ||
shell: bash | ||
run: | | ||
if [ "$secret" == "" ]; then | ||
echo ::set-output name=defined::false | ||
else | ||
echo ::set-output name=defined::true | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: "Test" | ||
description: "Test" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: ./.github/actions/cache | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
shell: bash | ||
- name: Run tests | ||
run: yarn test | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: "Validate dependencies" | ||
description: "Validate dependencies" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Check dependencies | ||
run: yarn audit --groups "dependencies" --level moderate | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.10.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Dev Node CI | ||
|
||
env: | ||
node-version: 16 | ||
node-package-manager: yarn | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
- "!master" | ||
- "!main" | ||
- "!develop" | ||
tags: | ||
- "**" | ||
- "!v*" | ||
|
||
jobs: | ||
cache-dependencies: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Access repository | ||
uses: actions/checkout@v2 | ||
- uses: ./.github/actions/cache | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: cache-dependencies | ||
steps: | ||
- name: Access repository | ||
uses: actions/checkout@v2 | ||
- uses: ./.github/actions/test | ||
|
||
validate-dependencies: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Access repository | ||
uses: actions/checkout@v2 | ||
- uses: ./.github/actions/validate-dependencies | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test | ||
- validate-dependencies | ||
steps: | ||
- name: Access repository | ||
uses: actions/checkout@v2 | ||
- uses: ./.github/actions/cache | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ${{ github.event.repository.name }}-develop | ||
path: dist | ||
|
||
check-docker-credentials: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
outputs: | ||
defined: ${{ steps.username.outputs.defined == 'true' && steps.password.outputs.defined == 'true' }} | ||
steps: | ||
- name: Access repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check if has username | ||
id: username | ||
uses: ./.github/actions/check-secret | ||
with: | ||
secret: ${{ secrets.DOCKER_USERNAME }} | ||
|
||
- name: Check if has password | ||
id: password | ||
uses: ./.github/actions/check-secret | ||
with: | ||
secret: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
publish-docker-image: | ||
runs-on: ubuntu-latest | ||
if: needs.check-docker-credentials.outputs.defined == 'true' | ||
needs: | ||
- check-docker-credentials | ||
steps: | ||
- name: Access repository | ||
uses: actions/checkout@v2 | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ github.event.repository.name }}-develop | ||
path: dist | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: "tv2media/${{ github.event.repository.name }}" | ||
tags: | | ||
type=ref,event=branch | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |