-
Notifications
You must be signed in to change notification settings - Fork 1
Pull changes from bloq/actions #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
63592c8
661f5eb
ab27f58
b471cbd
a1ac56d
baf8bb0
43cc730
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||
| # Copyright (c) 2024 Hemi Labs, Inc. | ||||||
| # Use of this source code is governed by the MIT License, | ||||||
| # which can be found in the LICENSE file. | ||||||
|
|
||||||
| name: Docker Checks | ||||||
|
|
||||||
| on: | ||||||
| workflow_call: | ||||||
| inputs: | ||||||
| context: | ||||||
| description: "The build context" | ||||||
| default: "." | ||||||
| type: string | ||||||
| fetch-depth: | ||||||
| description: Number of commits to fetch. 0 indicates all history for all branches and tags. | ||||||
| default: 1 | ||||||
| type: number | ||||||
|
|
||||||
| jobs: | ||||||
| docker-checks: | ||||||
| permissions: | ||||||
| contents: read | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
| - run: docker build --tag ${{ github.repository }}:${{ github.sha }} ${{ inputs.context }} | ||||||
| - uses: aquasecurity/trivy-action@0.29.0 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is a third-party action, not maintained by either GitHub or Docker, we should pin it to a commit hash in order to make it immutable.
Suggested change
https://github.com/aquasecurity/trivy-action/releases/tag/0.31.0 In addition to being third-party, this is also a security scanning tool. |
||||||
| with: | ||||||
| exit-code: 1 | ||||||
| ignore-unfixed: true | ||||||
| image-ref: ${{ github.repository }}:${{ github.sha }} | ||||||
| severity: HIGH,CRITICAL | ||||||
| skip-dirs: /root/.npm | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about moving this script to |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||
| #!/bin/sh | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is missing a copyright notice:
Suggested change
|
||||||||||||
|
|
||||||||||||
| set -e | ||||||||||||
|
|
||||||||||||
| # Get the version part to bump from the command line | ||||||||||||
| if [ -z "$1" ]; then | ||||||||||||
| echo "Use: ./bump-version <major, minor, patch>" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
| PART=$1 | ||||||||||||
|
|
||||||||||||
| # Get the current version parts from the latest tag | ||||||||||||
| LATEST_TAG=$(git tag -l "v*.*.*" --sort=-v:refname | head -n 1) | ||||||||||||
| CURRENT_VERSION=${LATEST_TAG#v} | ||||||||||||
| MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1) | ||||||||||||
| MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2) | ||||||||||||
| PATCH=$(echo "$CURRENT_VERSION" | cut -d. -f3) | ||||||||||||
|
|
||||||||||||
| # Bump the corresponding version part | ||||||||||||
| case $PART in | ||||||||||||
| major) | ||||||||||||
| MAJOR=$((MAJOR + 1)) | ||||||||||||
| MINOR=0 | ||||||||||||
| PATCH=0 | ||||||||||||
| ;; | ||||||||||||
| minor) | ||||||||||||
| MINOR=$((MINOR + 1)) | ||||||||||||
| PATCH=0 | ||||||||||||
| ;; | ||||||||||||
| patch) | ||||||||||||
| PATCH=$((PATCH + 1)) | ||||||||||||
| ;; | ||||||||||||
| *) | ||||||||||||
| echo "Unknown part '$PART'. Use 'major', 'minor', or 'patch'." | ||||||||||||
| exit 1 | ||||||||||||
| ;; | ||||||||||||
| esac | ||||||||||||
|
|
||||||||||||
| # Apply and push the new tags | ||||||||||||
| MAJOR_TAG="v$MAJOR" | ||||||||||||
| NEW_TAG="$MAJOR_TAG.$MINOR.$PATCH" | ||||||||||||
| git tag --force --message="" --sign "$MAJOR_TAG" | ||||||||||||
| git tag --message="" --sign "$NEW_TAG" | ||||||||||||
| git push --force origin "$NEW_TAG" "$MAJOR_TAG" | ||||||||||||
|
|
||||||||||||
| echo "Version bumped to '$NEW_TAG'" | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # Copyright (c) 2024 Hemi Labs, Inc. | ||
| # Use of this source code is governed by the MIT License, | ||
| # which can be found in the LICENSE file. | ||
|
|
||
| name: Docker Build and Push | ||
|
|
||
| author: Gabriel Montes | ||
|
|
||
| description: Build and push Docker images to Docker Hub | ||
|
|
||
| inputs: | ||
| context: | ||
| description: "The build context" | ||
| required: false | ||
| default: "." | ||
| dockerHubPassword: | ||
| description: "Docker Hub password" | ||
| required: true | ||
| dockerHubUsername: | ||
| description: "Docker Hub username" | ||
| required: true | ||
| images: | ||
| description: "The Docker image name" | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: docker/setup-buildx-action@v3 | ||
| - id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: ${{ inputs.images }} | ||
| tags: | | ||
| type=ref,event=branch | ||
| type=ref,event=pr | ||
| type=ref,event=tag | ||
| type=sha,prefix=,suffix=,format=short | ||
| - uses: docker/login-action@v3 | ||
| with: | ||
| password: ${{ inputs.dockerHubPassword }} | ||
| username: ${{ inputs.dockerHubUsername }} | ||
| - uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ${{ inputs.context }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| platforms: linux/amd64 | ||
| provenance: true | ||
| push: true | ||
| sbom: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
|
|
||
| branding: | ||
| color: blue | ||
| icon: box |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||
| # Copyright (c) 2024 Hemi Labs, Inc. | ||||||
| # Use of this source code is governed by the MIT License, | ||||||
| # which can be found in the LICENSE file. | ||||||
|
|
||||||
| name: Notify to Slack | ||||||
|
|
||||||
| author: Gabriel Montes | ||||||
|
|
||||||
| description: Send a notification to Slack using incoming webhooks | ||||||
|
|
||||||
| inputs: | ||||||
| app-name: | ||||||
| description: "The app being deployed" | ||||||
| required: true | ||||||
| environment: | ||||||
| description: "The deployment environment" | ||||||
| required: true | ||||||
| reference: | ||||||
| description: "Additional reference to add to the notification" | ||||||
| required: false | ||||||
| default: "" | ||||||
| slack-mention: | ||||||
| description: "The mention to include in the message" | ||||||
| default: <!here> | ||||||
| slack-webhook-url: | ||||||
| description: "The Slack incoming webhook URL" | ||||||
| required: true | ||||||
| status: | ||||||
| description: "The deployment status" | ||||||
| required: true | ||||||
|
|
||||||
| runs: | ||||||
| using: composite | ||||||
| steps: | ||||||
| - uses: slackapi/slack-github-action@v1 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is a third-party action, not maintained by either GitHub or Docker, we should pin it to a commit hash in order to make it immutable. Also, the latest version of this action is v2.1.0 (https://github.com/slackapi/slack-github-action/releases/tag/v2.1.0) - are we able to update? There is a migration guide here: https://github.com/slackapi/slack-github-action/releases/tag/v2.0.0
Suggested change
https://github.com/slackapi/slack-github-action/releases/tag/v1.27.1 |
||||||
| with: | ||||||
| payload: | | ||||||
| { | ||||||
| "text": ${{ toJSON(join(env.PAYLOAD_TEXT, '\n')) }} | ||||||
| } | ||||||
| env: | ||||||
| PAYLOAD_TEXT: | | ||||||
| ${{ format('{0} Deployment of {1} to {2} {3}', inputs.slack-mention, inputs.app-name, inputs.environment, inputs.status) }} | ||||||
| ${{ inputs.reference }} | ||||||
| SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook-url }} | ||||||
|
|
||||||
| branding: | ||||||
| color: blue | ||||||
| icon: bell | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Copyright (c) 2024 Hemi Labs, Inc. | ||
| # Use of this source code is governed by the MIT License, | ||
| # which can be found in the LICENSE file. | ||
|
|
||
| name: Publish to NPM | ||
|
|
||
| author: Gabriel Montes | ||
|
|
||
| description: Sets up Node, runs the prepublishOnly script and publishes the package to the NPM registry | ||
|
|
||
| inputs: | ||
| access: | ||
| description: Determines whether the published package should be publicly visible or restricted | ||
| required: false | ||
| default: public | ||
| token: | ||
| description: The NPM access token to use when publishing | ||
| required: true | ||
| provenance: | ||
| description: Attach provenance statements when publishing | ||
| required: false | ||
| default: "false" | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: hemilabs/actions/setup-node-env@v1 | ||
| - run: npm run --if-present prepublishOnly | ||
| shell: bash | ||
| - uses: JS-DevTools/npm-publish@19c28f1ef146469e409470805ea4279d47c3d35c # v3.1.1 (not audited by us) | ||
| with: | ||
| access: ${{ inputs.access }} | ||
| provenance: ${{ inputs.provenance }} | ||
| token: ${{ inputs.token }} | ||
|
|
||
| branding: | ||
| color: blue | ||
| icon: package | ||
|
gndelia marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4,21 +4,39 @@ | |||||
|
|
||||||
| name: Setup Node | ||||||
|
|
||||||
| description: Setups up Node.js, restores NPM cache and installs dependencies | ||||||
| author: Gabriel Montes | ||||||
|
|
||||||
| description: Setups up Node, restores NPM cache and installs dependencies | ||||||
|
|
||||||
| inputs: | ||||||
| cache: | ||||||
| description: "Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm." | ||||||
| default: npm | ||||||
| node-version: | ||||||
| description: The version of Node to install. | ||||||
| description: The version of Node to install | ||||||
| default: "" | ||||||
|
|
||||||
| runs: | ||||||
| using: composite | ||||||
| steps: | ||||||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | ||||||
| - uses: pnpm/action-setup@v4.0.0 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is a third-party action, not maintained by either GitHub or Docker, we should pin it to a commit hash in order to make it immutable. Also, a minor update is available: https://github.com/pnpm/action-setup/releases/tag/v4.1.0 (changes: pnpm/action-setup@v4.0.0...v4.1.0)
Suggested change
https://github.com/pnpm/action-setup/releases/tag/v4.1.0 |
||||||
| if: ${{ inputs.cache == 'pnpm' }} | ||||||
| - uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| cache: npm | ||||||
| cache-dependency-path: "**/package-lock.json" | ||||||
| cache: ${{ inputs.cache }} | ||||||
| cache-dependency-path: ${{ inputs.cache == 'npm' && '**/package-lock.json' || '' }} | ||||||
| node-version: ${{ inputs.node_version }} | ||||||
| node-version-file: .nvmrc | ||||||
| - run: npm ci | ||||||
| shell: bash | ||||||
| if: ${{ inputs.cache == 'npm' }} | ||||||
| - run: pnpm install --frozen-lockfile | ||||||
| shell: bash | ||||||
| if: ${{ inputs.cache == 'pnpm' }} | ||||||
| - run: yarn install --immutable | ||||||
| shell: bash | ||||||
| if: ${{ inputs.cache == 'yarn' }} | ||||||
|
gabmontes marked this conversation as resolved.
|
||||||
|
|
||||||
| branding: | ||||||
| color: blue | ||||||
| icon: code | ||||||
Uh oh!
There was an error while loading. Please reload this page.