-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
306edc5
commit c7b5a0b
Showing
1 changed file
with
69 additions
and
5 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 |
---|---|---|
@@ -1,17 +1,81 @@ | ||
name: wcl github actions workflow | ||
on: | ||
workflow_call: | ||
inputs: | ||
project_name: | ||
required: true | ||
type: string | ||
component_name: | ||
required: true | ||
type: string | ||
node_env: | ||
required: false | ||
type: string | ||
default: 'production' | ||
dockerfile_path: | ||
description: 'the path where docker build execute.' | ||
required: false | ||
default: './' | ||
type: string | ||
secrets: | ||
HARBOR_GH_ACTIONS_USERNAME: | ||
required: true | ||
HARBOR_CN_GH_ACTIONS_PASSWORD: | ||
required: true | ||
HARBOR_CN: | ||
required: true | ||
NPM_TOKEN: | ||
required: true | ||
jobs: | ||
echo_msg: | ||
name: echo msg | ||
build: | ||
name: build | ||
# runs-on: ubuntu-latest | ||
runs-on: ubuntu-latest | ||
runs-on: cn | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: "0" | ||
# - name: show msg | ||
# run: echo "hello world" | ||
|
||
# Scan repo for secrets | ||
- name: Run scanner for the repository | ||
run: /usr/local/bin/whispers ${{ github.workspace }} > /tmp/scan_output.json | ||
|
||
# Upload Artifacts | ||
- name: Upload the scan output | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: scan_results | ||
path: /tmp/scan_output.json | ||
retention-days: 2 | ||
|
||
# Extract metadata (tags, labels) for Docker | ||
# https://github.com/docker/metadata-action | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ secrets.HARBOR_CN }}/${{ inputs.project_name }}/${{ inputs.component_name }} | ||
|
||
- name: Login to PrivateRegistry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ secrets.HARBOR_CN }} | ||
username: ${{ secrets.HARBOR_GH_ACTIONS_USERNAME }} | ||
password: ${{ secrets.HARBOR_CN_GH_ACTIONS_PASSWORD }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ${{ inputs.dockerfile_path }} | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
OMNI_COMPONENT=${{ inputs.component_name }} | ||
NODE_ENV=${{ inputs.node_env }} | ||
NPM_TOKEN=${{ secrets.NPM_TOKEN }} | ||
OMNI_COMPONENT_COMMIT=${{ github.sha }} | ||
OMNI_COMPONENT_VERSION=${{ github.ref }} |