-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (97 loc) · 3.85 KB
/
Copy pathprepare-solution.yaml
File metadata and controls
111 lines (97 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Chainlink (all in one) - prepare solution
on:
workflow_dispatch:
inputs:
target:
description: 'Target'
required: true
default: 'develop'
type: choice
options:
- develop
- stage
- testnet
- mainnet
argo_commit_type:
description: 'Argo commit type'
required: true
default: 'pull-request'
type: choice
options:
- pull-request
- direct-commit
env:
SOLUTION: chainlink-all-in-one-image-${{ inputs.target }}
IMAGE_FILE: ''
IMAGE_RESOURCE: ''
PR_REPO_ARGO: super-protocol/argocd-clusters
DOCKERFILE: dockerfile.allinone
TARGET: ${{ inputs.target }}
jobs:
build-and-update-offer:
runs-on: ubuntu-latest
steps:
- name: Validate inputs
env:
TARGET: ${{ inputs.target }}
ARGO: ${{ inputs.argo_commit_type }}
run: |
if [[ "$TARGET" == "mainnet" && "$ARGO" == "direct-commit" ]]; then
echo "Error: when target=mainnet, argo_commit_type=direct-commit is not allowed."
exit 1
fi
- name: Import secrets from Vault
id: import-secrets
uses: hashicorp/vault-action@v2
with:
url: ${{ secrets.VAULT_ADDR }}
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
github/data/${{ env.TARGET }}/spctl offers_config_json | OFFERS_SPCTL_CONFIG_JSON ;
github/data/${{ env.TARGET }}/chainlink config_public_key_base64 | CONFIG_PUBLIC_KEY_BASE64
- name: Display Run Information
run: |
echo "### Workflow Run Details (STUB)" >> $GITHUB_STEP_SUMMARY
echo "- **Triggered from branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Selected Target Environment:** \`${{ inputs.target }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **This is a stub workflow for testing purposes**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
driver-opts: |
image=moby/buildkit:v0.12.0
- name: Build Docker image and save to file
run: |
IMAGE_FILE="$SOLUTION-b${{ github.run_id }}.tar.gz"
docker build -t chainlink-all-in-one:latest -f $DOCKERFILE --build-arg CONFIGURATION_PUBLIC_KEY=${{ toJSON(steps.import-secrets.outputs.CONFIG_PUBLIC_KEY_BASE64) }} .
docker save chainlink-all-in-one:latest | gzip > $IMAGE_FILE
echo "IMAGE_FILE=$IMAGE_FILE" >> $GITHUB_ENV
- name: Set SPCTL repository type
run: |
echo "SPCTL_REPOSITORY_TYPE=${{ (inputs.target == 'testnet' || inputs.target == 'mainnet') && 'public' || 'private' }}" >> $GITHUB_ENV
- name: Prepare SPCTL config
run: |
printf '%s' '${{ toJSON(steps.import-secrets.outputs.OFFERS_SPCTL_CONFIG_JSON) }}' | jq -r . > ./config.json
- name: Download and install SPCTL
uses: Super-Protocol/sp-build-tools/actions/download-spctl@v1
with:
repository: ${{ env.SPCTL_REPOSITORY_TYPE }}
gh_token: ${{ secrets.GHFG_TOKEN_SPCTL_RELEASES_DOWNLOAD }}
- name: Encrypt and upload image
id: upload_image
uses: Super-Protocol/sp-build-tools/actions/upload-file@v1
with:
file_to_upload: ${{ env.IMAGE_FILE }}
- name: Update argocd
uses: Super-Protocol/sp-build-tools/actions/update-argocd@v1
with:
gh_token: ${{ secrets.TOKEN_FOR_ARGOCD_REPO }}
target: ${{ env.TARGET }}
resource_type: solution
resource_file: ${{ steps.upload_image.outputs.resource }}
solution_name: ${{ env.SOLUTION }}
commit_type: ${{ inputs.argo_commit_type }}