-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/dappforce/private-subid-api
- Loading branch information
Showing
21 changed files
with
301 additions
and
418 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,77 @@ | ||
name: Common CD setup | ||
description: 'Sets up the environment for jobs during CD' | ||
|
||
inputs: | ||
token_input: | ||
description: "the k8s temporary creds" | ||
required: true | ||
k8s_input: | ||
description: "the cluster name" | ||
required: true | ||
app_input: | ||
description: "the App name" | ||
required: true | ||
zone_input: | ||
description: "the cf zone" | ||
required: true | ||
mail_input: | ||
description: "the cf mail" | ||
required: true | ||
tokens_input: | ||
description: "the cf token" | ||
required: true | ||
prod_deploy: | ||
description: "deploy to prod or not, Boolean" | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Extract main branch name | ||
if: github.ref == 'refs/heads/main' | ||
shell: bash | ||
run: echo "name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | ||
id: extract_branch | ||
|
||
- name: Extract feature branch name | ||
if: startsWith(github.ref, 'refs/heads/deploy/') | ||
shell: bash | ||
run: echo "name=$(echo ${GITHUB_REF#refs/heads/} | sed 's/^deploy\///')" >> $GITHUB_ENV | ||
id: extract_features_branch | ||
|
||
- name: Prepare | ||
id: prep | ||
shell: bash | ||
run: | | ||
echo "image=dappforce/subid-backend:${{ inputs.app_input }}-${{ env.name }}-$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_ENV | ||
- name: Install doctl | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ inputs.token_input }} | ||
|
||
- name: Save DigitalOcean kubeconfig with short-lived credentials | ||
shell: bash | ||
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ inputs.k8s_input }} | ||
|
||
- name: Add feature name | ||
if: startsWith(github.ref, 'refs/heads/deploy/') | ||
shell: bash | ||
run: | | ||
NAME=${{ env.name }} && sed -i 's|<BRANCH>|'${NAME}'|' $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/all.yaml | ||
NAME=${{ env.name }} && sed -i 's|<BRANCH>|'${NAME}'|' $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/deployment.yaml | ||
sed -i 's|<IMAGE>|'${{ env.image }}'|' $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/deployment.yaml | ||
curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ inputs.zone_input }}/dns_records" -H "X-Auth-Email:${{ inputs.mail_input }}" -H "Authorization:Bearer ${{ inputs.tokens_input }}" -H "Content-Type:application/json" --data '{"type":"A","name":"${{ env.name }}-subid.subsocial.network","content":"174.138.105.155","ttl":3600,"priority":10,"proxied":true}' | ||
kubectl apply -f $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/ | ||
- name: make ${{ inputs.app_input }} ready | ||
if: github.ref == 'refs/heads/main' && inputs.prod_deploy == false | ||
shell: bash | ||
run: | | ||
sed -i 's|<IMAGE>|'${{ env.image }}'|' $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/daemon.yaml | ||
kubectl apply -f $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/daemon.yaml | ||
kubectl -n sub-id rollout status daemonset/back-ready | ||
kubectl delete -f $GITHUB_WORKSPACE/deployment/${{ inputs.app_input }}/daemon.yaml |
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,82 @@ | ||
name: Common CI setup | ||
description: 'Sets up the environment for jobs during CI' | ||
|
||
inputs: | ||
username_input: | ||
description: "the DockerHub username" | ||
required: true | ||
password_input: | ||
description: "the DockerHub password" | ||
required: true | ||
app_input: | ||
description: "the App name" | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Extract main branch name | ||
if: github.ref == 'refs/heads/main' | ||
shell: bash | ||
run: echo "name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | ||
id: extract_branch | ||
|
||
- name: Extract feature branch name | ||
if: startsWith(github.ref, 'refs/heads/deploy/') | ||
shell: bash | ||
run: echo "name=$(echo ${GITHUB_REF#refs/heads/} | sed 's/^deploy\///')" >> $GITHUB_ENV | ||
id: extract_features_branch | ||
|
||
- name: Set up Docker context for buildx | ||
id: buildx-context | ||
shell: bash | ||
run: | | ||
docker context create builders | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@master | ||
with: | ||
endpoint: builders | ||
version: latest | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@master | ||
with: | ||
username: ${{ inputs.username_input }} | ||
password: ${{ inputs.password_input }} | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v4 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-single-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-single-buildx | ||
- name: Prepare | ||
id: prep | ||
shell: bash | ||
run: | | ||
echo "image=dappforce/subid-backend:${{ inputs.app_input }}-${{ env.name }}-$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_ENV | ||
- name: Build image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
builder: ${{ steps.buildx.outputs.name }} | ||
file: docker/Dockerfile | ||
push: true | ||
tags: | | ||
${{ env.image }} | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new | ||
|
||
- name: Move cache | ||
shell: bash | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
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
Oops, something went wrong.