-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix-cli-args
- Loading branch information
Showing
75 changed files
with
8,127 additions
and
2,743 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,71 @@ | ||
name: 'Build Docker Images' | ||
description: 'Builds Docker images and pushes them to any repository.' | ||
inputs: | ||
DOCKER_FILENAME: | ||
description: 'Name of the docker file to use for the build' | ||
required: true | ||
REPOSITORY_NAME: | ||
description: 'Name of the Repository' | ||
required: true | ||
IMAGE_TAG: | ||
description: 'Image Tag' | ||
required: true | ||
REGISTRY: | ||
description: 'Docker or ORG you want to push to.' | ||
required: true | ||
DOCKER_ORG: | ||
description: 'Docker ORG you want to push to.' | ||
required: false | ||
USERNAME: | ||
description: 'Username for GitHub Container Registry' | ||
required: true | ||
TOKEN: | ||
description: 'Token for GitHub Container Registry' | ||
required: true | ||
DOCKER_FILE_DIRECTORY: | ||
description: 'Directory for your Dockerfile' | ||
required: true | ||
DOCKER_BUILD_KIT: | ||
description: "whether or not to use docker build kit." | ||
required: true | ||
TAG_LATEST: | ||
description: "should the pipeline tag latest" | ||
required: true | ||
runs: | ||
using: "composite" | ||
|
||
steps: | ||
- name: Set Environment Variables" | ||
run: | | ||
echo "DOCKER_BUILDKIT=${{ inputs.DOCKER_BUILD_KIT }}" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Log in to the Docker Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.REGISTRY }} | ||
username: ${{ inputs.USERNAME }} | ||
password: ${{ inputs.TOKEN }} | ||
|
||
- name: Build, tag, and push images | ||
shell: bash | ||
working-directory: ${{ inputs.DOCKER_FILE_DIRECTORY }} | ||
run: | | ||
if [ ! -z "${{ inputs.DOCKER_ORG }}" ]; then | ||
echo "DOCKER ORG SPECIFIED SO USE DOCKER HUB" | ||
docker build -f ${{ inputs.DOCKER_FILENAME }} -t ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} . | ||
docker push ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} | ||
if [ "${{ inputs.TAG_LATEST }}" == "true" ]; then | ||
docker tag ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:latest | ||
docker push ${{ inputs.DOCKER_ORG }}/${{ inputs.REPOSITORY_NAME }}:latest | ||
fi | ||
else | ||
echo "DOCKER REGISTRY SPECIFIED WITH NO DOCKER_ORG USE NON ORG REGISTRIES" | ||
docker build -f ${{ inputs.DOCKER_FILENAME }} -t ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} . | ||
docker push ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} | ||
if [ "${{ inputs.TAG_LATEST }}" == "true" ]; then | ||
docker tag ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:${{ inputs.IMAGE_TAG }} ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:latest | ||
docker push ${{ inputs.REGISTRY }}/${{ inputs.REPOSITORY_NAME }}:latest | ||
fi | ||
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 |
---|---|---|
|
@@ -138,6 +138,6 @@ jobs: | |
- name: Clean Up Workspace | ||
if: always() | ||
shell: bash | ||
run: rm -rf * | ||
run: sudo rm -rf * | ||
|
||
|
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: Zetacored-Docker-Build | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
branches: | ||
- 'main' | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Docker Tag Version For Manual Execution' | ||
required: false | ||
default: '' | ||
|
||
concurrency: | ||
group: Zetacored-Docker-Build | ||
cancel-in-progress: false | ||
|
||
env: | ||
DOCKER_REPO: "zeatcored" | ||
DOCKER_ORG: "zetachain" | ||
DOCKER_REGISTRY: "https://index.docker.io/v1/" | ||
|
||
jobs: | ||
docker_build_ubuntu: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set Version from the PR title. | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV} | ||
- name: Set Version for Hotfix Release from Input. | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV} | ||
- name: "BUILD:PUSH:MONITORING:DOCKER:IMAGE" | ||
uses: ./.github/actions/build-docker-images-generic | ||
with: | ||
DOCKER_FILENAME: "Dockerfile" | ||
REPOSITORY_NAME: "${{ env.DOCKER_REPO }}" | ||
IMAGE_TAG: "ubuntu-${{ env.GITHUB_TAG_MAJOR_VERSION }}" | ||
REGISTRY: "${{ env.DOCKER_REGISTRY }}" | ||
DOCKER_ORG: "${{ env.DOCKER_ORG }}" | ||
USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}" | ||
TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}" | ||
DOCKER_FILE_DIRECTORY: "./" | ||
DOCKER_BUILD_KIT: "0" | ||
TAG_LATEST: "true" | ||
|
||
docker_build_mac: | ||
runs-on: macos-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set Version from the PR title. | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV} | ||
- name: Set Version for Hotfix Release from Input. | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV} | ||
- name: "BUILD:PUSH:MONITORING:DOCKER:IMAGE" | ||
uses: ./.github/actions/build-docker-images-generic | ||
with: | ||
DOCKER_FILENAME: "Dockerfile" | ||
REPOSITORY_NAME: "${{ env.DOCKER_REPO }}" | ||
IMAGE_TAG: "mac-${{ env.GITHUB_TAG_MAJOR_VERSION }}" | ||
REGISTRY: "${{ env.DOCKER_REGISTRY }}" | ||
DOCKER_ORG: "${{ env.DOCKER_ORG }}" | ||
USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}" | ||
TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}" | ||
DOCKER_FILE_DIRECTORY: "./" | ||
DOCKER_BUILD_KIT: "0" | ||
TAG_LATEST: "false" | ||
|
||
docker_build_arm: | ||
runs-on: buildjet-4vcpu-ubuntu-2204-arm | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set Version from the PR title. | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.pull_request.title }}" >> ${GITHUB_ENV} | ||
- name: Set Version for Hotfix Release from Input. | ||
if: github.event_name != 'pull_request' | ||
run: | | ||
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV} | ||
- name: "BUILD:PUSH:MONITORING:DOCKER:IMAGE" | ||
uses: ./.github/actions/build-docker-images-generic | ||
with: | ||
DOCKER_FILENAME: "Dockerfile" | ||
REPOSITORY_NAME: "${{ env.DOCKER_REPO }}" | ||
IMAGE_TAG: "arm-${{ env.GITHUB_TAG_MAJOR_VERSION }}" | ||
REGISTRY: "${{ env.DOCKER_REGISTRY }}" | ||
DOCKER_ORG: "${{ env.DOCKER_ORG }}" | ||
USERNAME: "${{ secrets.DOCKER_HUB_USERNAME }}" | ||
TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}" | ||
DOCKER_FILE_DIRECTORY: "./" | ||
DOCKER_BUILD_KIT: "0" | ||
TAG_LATEST: "false" |
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
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
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
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,67 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/aes" | ||
"crypto/cipher" | ||
"crypto/rand" | ||
"crypto/sha256" | ||
"encoding/json" | ||
"errors" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var encTssCmd = &cobra.Command{ | ||
Use: "tss-encrypt [file-path] [secret-key]", | ||
Short: "Utility command to encrypt existing tss key-share file", | ||
Args: cobra.ExactArgs(2), | ||
RunE: EncryptTSSFile, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(encTssCmd) | ||
} | ||
|
||
func EncryptTSSFile(_ *cobra.Command, args []string) error { | ||
filePath := args[0] | ||
secretKey := args[1] | ||
|
||
filePath = filepath.Clean(filePath) | ||
data, err := os.ReadFile(filePath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !json.Valid(data) { | ||
return errors.New("file does not contain valid json, may already be encrypted") | ||
} | ||
|
||
block, err := aes.NewCipher(getFragmentSeed(secretKey)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Creating GCM mode | ||
gcm, err := cipher.NewGCM(block) | ||
if err != nil { | ||
return err | ||
} | ||
// Generating random nonce | ||
nonce := make([]byte, gcm.NonceSize()) | ||
if _, err := io.ReadFull(rand.Reader, nonce); err != nil { | ||
return err | ||
} | ||
|
||
cipherText := gcm.Seal(nonce, nonce, data, nil) | ||
return os.WriteFile(filePath, cipherText, 0o600) | ||
} | ||
|
||
func getFragmentSeed(password string) []byte { | ||
h := sha256.New() | ||
h.Write([]byte(password)) | ||
seed := h.Sum(nil) | ||
return seed | ||
} |
Oops, something went wrong.