Skip to content

Commit

Permalink
add deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
alvicsam committed Oct 30, 2024
1 parent 4a81615 commit ffb412d
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 11 deletions.
15 changes: 4 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- master
tags:
- v*
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand Down Expand Up @@ -39,8 +37,10 @@ jobs:
export REF_SLUG=${REF_NAME//\//_}
if [[ ${REF_SLUG} == "master" ]]
then
VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}
echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT
else
VERSION=${REF_SLUG}
echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT
fi
echo "set VERSION=${VERSION}"
Expand Down Expand Up @@ -212,7 +212,7 @@ jobs:
mv -v ./ci.Dockerfile ./artifacts/
- name: upload artifacts
uses: actions/upload-artifact@v3 #b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
uses: actions/upload-artifact@v3
with:
name: build
path: ./artifacts
Expand All @@ -226,7 +226,7 @@ jobs:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v3 #fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@v3
with:
name: build
- name: Make scripts executable
Expand All @@ -239,13 +239,6 @@ jobs:
context: .
file: ./ci.Dockerfile
push: false
# build-args:
tags: |
docker.io/paritytech/substrate-relay:${{ env.VERSION }}
docker.io/paritytech/bridges-common-relay:${{ env.VERSION }}
#build image substrate-relay
#build image bridges-common-relay
#build and push image substrate-relay
#build and push image bridges-common-relay
#deploy argocd
123 changes: 123 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Deploy

on:
push:
tags:
- v*

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# common variable is defined in the workflow
# repo env variable doesn't work for PR from forks
env:
CI_IMAGE: "paritytech/ci-unified:bullseye-1.81.0-2024-09-11-v202409111034"

jobs:
set-variables:
# This workaround sets the container image for each job using 'set-variables' job output.
# env variables don't work for PR from forks, so we need to use outputs.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- name: Set image
id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT
- name: Define version
id: version
run: |
export COMMIT_SHA=${{ github.sha }}
export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8}
export REF_NAME=${{ github.ref_name }}
export REF_SLUG=${REF_NAME//\//_}
if [[ ${REF_SLUG} == "master" ]]
then
VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}
echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT
else
VERSION=${REF_SLUG}
echo "VERSION=${REF_SLUG}" >> $GITHUB_OUTPUT
fi
echo "set VERSION=${VERSION}"
build:
name: Build
runs-on: parity-large
needs: [set-variables]
container:
image: ${{ needs.set-variables.outputs.CI_IMAGE }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Build and pack artifact
run: |
cargo fetch
CARGO_NET_OFFLINE=true time cargo build --release --workspace
mkdir -p ./artifacts
strip ./target/release/substrate-relay
mv -v ./target/release/substrate-relay ./artifacts/
mv -v ./deployments/local-scripts/bridge-entrypoint.sh ./artifacts/
mv -v ./ci.Dockerfile ./artifacts/
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: ./artifacts
retention-days: 2

build_push_docker:
name: Build docker image
runs-on: ubuntu-latest
needs: [set-variables, build]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: build
- name: Make scripts executable
run: |
chmod +x bridge-entrypoint.sh
chmod +x substrate-relay
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./ci.Dockerfile
push: true
tags: |
docker.io/paritytech/substrate-relay:${{ env.VERSION }}
docker.io/paritytech/bridges-common-relay:${{ env.VERSION }}
deploy-westend:
name: Deploy Westend
runs-on: ubuntu-latest
environment: parity-testnet
needs: [set-variables, build_push_docker]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
ARGOCD_SERVER: "westend-argocd.teleport.parity.io"
steps:
- name: Deploy to ArgoCD
uses: paritytech/argocd-deployment-action@main
with:
environment: "parity-testnet"
tag: "${{ env.VERSION }}"
app_name: "bridges-common-relay"
app_packages: "headers-a,headers-b,parachains-a,parachains-b,messages-a,messages-b"
argocd_server: ${{ env.ARGOCD_SERVER }}
teleport_token: ${{ env.APP }}
teleport_app_name: "argocd-testnet"
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }}

0 comments on commit ffb412d

Please sign in to comment.