Skip to content

Commit

Permalink
test deploy to hetzner
Browse files Browse the repository at this point in the history
  • Loading branch information
shpookas committed Sep 3, 2024
1 parent 4e488e9 commit 56097c3
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/hetzner-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: decentralized-feeder-pull-request-pipeline

on:
push:
branches:
- deployment-to-civo-hetzner

jobs:
push_image:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- uses: actions/checkout@v4

# Checkout the cluster-backend repository
- name: Checkout cluster-backend repository
env:
TOKEN: ${{ secrets.PIPELINE_TOKEN }}
run: |
git clone https://$TOKEN@github.com/diadata-org/cluster-backend cluster-backend
# Install IBM Cloud CLI and Container Registry CLI
- name: Install IBM Cloud CLI
run: |
curl -fsSL https://clis.cloud.ibm.com/install/linux | sh
ibmcloud plugin install container-registry -f
# Log in to IBM Cloud
- name: Log in to IBM Cloud
env:
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
run: |
ibmcloud login --apikey $IBM_CLOUD_API_KEY --no-region
ibmcloud target -r us-south
ibmcloud target -g Default
# Get Unix Timestamp
- name: Get Unix Timestamp
id: get_timestamp
run: echo "TIMESTAMP=$(date +%s)" >> $GITHUB_ENV

# Build and Tag the Docker image
- name: Build and Tag Docker image
run: |
docker build -f build/Dockerfile-diaDecentralOracleService -t us.icr.io/dia-registry/oracles/diadecentraloracleservice:unix-${{ env.TIMESTAMP }} .
# Push the Docker image to IBM Cloud Container Registry
- name: Push Docker image
run: |
ibmcloud cr login
docker push us.icr.io/dia-registry/oracles/diadecentraloracleservice:unix-${{ env.TIMESTAMP }}
# Install kubectl
- name: Install kubectl
run: |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
# kubectl config with service account
- name: Configure kubectl with Service Account
env:
TOKEN: ${{ secrets.K8S_SERVICE_ACCOUNT_TOKEN_HETZNER }}
CLUSTER_NAME: ${{ secrets.K8s_CLUSTER_NAME_HETZNER }}
CONTEXT: ${{ secrets.K8s_CONTEXT_HETZNER }}
API_SERVER: ${{ secrets.K8S_API_SERVER_HETZNER }} # Example: https://your-api-server:6443
run: |
# Ensure token does not contain unexpected newline characters
TOKEN=$(echo "$TOKEN" | tr -d '\n')
# Set cluster
kubectl config set-cluster "$CLUSTER_NAME" --server="$API_SERVER" --insecure-skip-tls-verify=true
# Set credentials
kubectl config set-credentials github-actions-sa --token="$TOKEN"
# Set context
kubectl config set-context $CONTEXT --cluster="$CLUSTER_NAME" --user=github-actions-sa
# Use context
kubectl config use-context $CONTEXT
# Helm upgrade command
- name: Helm upgrade/install conduit-node-013
run: |
cd cluster-backend/helmcharts/oracles/conduit-test/013
helm upgrade --install -n dia-lumina --set repository.tag="unix-${{ env.TIMESTAMP }}" diaoracleservice-conduit-013 .
# Cleanup the cloned repository
- name: Cleanup cloned repository
run: |
rm -rf cluster-backend

0 comments on commit 56097c3

Please sign in to comment.