Skip to content

Sync dev and staging central after release #95

Sync dev and staging central after release

Sync dev and staging central after release #95

name: Sync dev and staging central after release
on:
workflow_dispatch:
inputs:
release_tag:
description: Release version
required: true
default: 2201.0.3
code_name:
description: Version code name
required: true
default: swan-lake
update_env:
description: Central environment to be synced
required: true
default: staging
type: choice
options:
- staging
- dev
jobs:
update-staging-and-dev-central:
runs-on: ubuntu-latest
env:
BAL_VERSION_CODE_NAME: ${{github.event.inputs.code_name}}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Extract version ID
if: contains(${{github.event.inputs.release_tag}}, '-rc')
uses: rishabhgupta/split-by@v1
id: split_version
with:
string: ${{github.event.inputs.release_tag}}
split-by: '-'
- name: Download Ballerina distribution zip
uses: wei/wget@v1
with:
args:
https://github.com/ballerina-platform/ballerina-distribution/releases/download/v${{github.event.inputs.release_tag}}/ballerina-${{steps.split_version.outputs._0}}-${{env.BAL_VERSION_CODE_NAME}}.zip
- name: Extract Ballerina distribution
run: unzip -qq ./ballerina-${{steps.split_version.outputs._0}}-${{env.BAL_VERSION_CODE_NAME}}.zip -d .
- run: rm ballerina-${{steps.split_version.outputs._0}}-${{env.BAL_VERSION_CODE_NAME}}.zip
- name: Execute Ballerina script
uses: ballerina-platform/[email protected]
with:
args: run ./dependabot/sync_dev_and_staging_central.bal
env:
BAL_VERSION_ID: ${{steps.split_version.outputs._0}}
- name: Iterate through modules and compress to .bala
run: |
mkdir ./bala-archive
cd ./bala ;
for dir in */; do
cd ./$dir ; zip -r ../../bala-archive/${dir::-1}.bala . ; cd ..
done
- name: Push to staging central
if: ${{github.event.inputs.update_env == 'staging'}}
run: |
cd ./bala-archive ;
upload_failure=false
for dir in *; do
echo -e "\n" $dir ;
response=$(curl -X POST -w "\n" -H "Content-Type:application/octet-stream" \
-H "Authorization: Bearer ${{secrets.BALLERINA_CENTRAL_STAGE_ACCESS_TOKEN}}" \
--data-binary @"$dir" https://api.staging-central.ballerina.io/2.0/registry/packages ;)
if [ -z "$response" ]; then
echo "Upload Success";
else
echo $response;
upload_failure=true;
fi;
done
if $upload_failure ; then
exit 1;
fi;
- name: Push to dev central
if: ${{github.event.inputs.update_env == 'dev'}}
run: |
cd ./bala-archive ;
upload_failure=false
for dir in *; do
echo -e "\n" $dir ;
response=$(curl -X POST -w "\n" -H "Content-Type:application/octet-stream" \
-H "Authorization: Bearer ${{secrets.BALLERINA_CENTRAL_DEV_ACCESS_TOKEN}}" \
--data-binary @"$dir" https://api.dev-central.ballerina.io/2.0/registry/packages ;)
if [ -z "$response" ]; then
echo "Upload Success";
else
echo $response;
upload_failure=true;
fi;
done
if $upload_failure ; then
exit 1;
fi;