New xdc zero #94
Workflow file for this run
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
name: Build and deploy devnet | |
on: | |
pull_request_target: | |
branches: | |
- master | |
jobs: | |
build_and_deploy: | |
if: | | |
( startsWith(github.head_ref, 'feature') || | |
startsWith(github.head_ref, 'fix') ) | |
name: Test and deploy on PR | |
runs-on: ubuntu-latest | |
steps: | |
- name: check out code | |
uses: actions/checkout@master | |
- name: check out trigger branch | |
run: | | |
git fetch origin $BRANCH | |
git checkout $BRANCH | |
env: | |
BRANCH: ${{ github.head_ref }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Install dependencies | |
run: npm install && npm run postinstall | |
- name: Unit tests | |
run: npm run test | |
- name: Build test | |
run: npm run build | |
- name: Record branch env | |
id: branch | |
run: | | |
echo "repo=${{ github.repository }}" >> $GITHUB_OUTPUT | |
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT | |
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
# echo $repo | |
# echo $branch | |
# echo $commit | |
- name: Docker login | |
env: | |
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_ACCESS_TOKEN}} | |
run: | | |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | |
- name: Determine Docker Image Name | |
id: image | |
run: | | |
echo "name=xinfinorg/xdc-relayer:${{ steps.branch.outputs.branch }}" >> $GITHUB_OUTPUT | |
- name: Docker build and push image | |
run: | | |
docker build . --file Dockerfile --tag ${{ steps.image.outputs.name }} | |
docker push ${{ steps.image.outputs.name }} | |
- name: trigger deploy workflow | |
id: trigger_deploy | |
run: | | |
echo "RESPONSE_CODE=$( \ | |
curl -L \ | |
-o response.txt \ | |
-w %{response_code} \ | |
-s \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.CICD_PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/hash-laboratories-au/subnet-deployment/actions/workflows/subnet-deploy.yaml/dispatches \ | |
-d '{"ref":"master", "inputs":{"caller_repo": "${{ steps.branch.outputs.repo }}", "caller_ref": "${{ steps.branch.outputs.branch }}", "caller_sha": "${{ steps.branch.outputs.commit }}"}}' \ | |
)" >> $GITHUB_ENV | |
- name: Check response fail or success | |
run: | | |
cat response.txt | |
echo "RESPONSE_CODE=${{ env.RESPONSE_CODE }}" | |
if [ ${{ env.RESPONSE_CODE }} != 204 ] | |
then | |
exit 1 | |
fi | |