Skip to content

Commit

Permalink
Update reused_workflow.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
victorchen2022 authored Apr 28, 2022
1 parent 306edc5 commit c7b5a0b
Showing 1 changed file with 69 additions and 5 deletions.
74 changes: 69 additions & 5 deletions .github/workflows/reused_workflow.yml
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 }}

0 comments on commit c7b5a0b

Please sign in to comment.