Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jclark committed Jul 25, 2022
2 parents b6121d6 + bb9d351 commit 9f334c9
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .github/scripts/update_specs_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import requests
import sys
import shutil
import os

response = requests.get("https://api.github.com/repos/ballerina-platform/ballerina-spec/releases/latest")

updated_spec = open("updated_spec.md", 'a')

spec_version = response.json()["name"]
release_date = response.json()["published_at"][0:10]
release_note = response.json()["body"]

with open(sys.argv[1],'r') as read_obj:
for line in read_obj.readlines():
if "| ------- | ------------ | ----------- |" in line:
updated_spec.write(line)
updated_spec.write('| <a target="_blank" href="/spec/lang/'+spec_version+'/">'+spec_version+'</a> | '+release_date+' | '+release_note+' |\n')
continue
updated_spec.write(line)

os.remove(sys.argv[1])
shutil.copy("updated_spec.md",sys.argv[1])
67 changes: 67 additions & 0 deletions .github/workflows/delete_draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Delete draft spec release in ballerina.io

on:
workflow_dispatch:
inputs:
version:
description: 'Version of the draft (directory name)'
required: true
default: ''

jobs:
delete_release_spec:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}

steps:
- name: Checkout ballerina-spec
uses: actions/checkout@v2

- name: Clone ballerina-dev-website
run: git clone -b master --single-branch https://ballerina-bot:[email protected]/ballerina-platform/ballerina-dev-website.git

- name: Clone ballerina-prod-website
run: git clone https://ballerina-bot:[email protected]/ballerina-platform/ballerina-platform.github.io.git

- name: Delete spec directory from ballerina-dev-website
run: |
cd ballerina-dev-website
git pull origin master
git config --global user.email "[email protected]"
git config --global user.name "ballerina-bot"
if [ -d "spec/lang/draft/${{ github.event.inputs.version }}" ]; then rm -Rf "spec/lang/draft/${{ github.event.inputs.version }}"; else echo "${{ github.event.inputs.version }} directory not found"; fi
git add spec/lang/draft
git commit --allow-empty -m "[Automated] Delete draft in master"
- name: Delete spec directory from ballerina-prod-website
run: |
cd ballerina-platform.github.io
git pull origin master
git config --global user.email "[email protected]"
git config --global user.name "ballerina-bot"
if [ -d "spec/lang/draft/${{ github.event.inputs.version }}" ]; then rm -Rf "spec/lang/draft/${{ github.event.inputs.version }}"; else echo "${{ github.event.inputs.version }} directory not found"; fi
git add spec/lang/draft
git commit --allow-empty -m "[Automated] Delete draft in master"
- name: Push new changes to ballerina-dev-website
shell: bash
run: |
cd ballerina-dev-website
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}

- name: Push new changes to ballerina-prod-website
shell: bash
run: |
cd ballerina-platform.github.io
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}
67 changes: 67 additions & 0 deletions .github/workflows/delete_major_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Delete major spec release in ballerina.io

on:
workflow_dispatch:
inputs:
version:
description: 'Version of the spec release (directory name)'
required: true
default: ''

jobs:
delete_release_spec:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}

steps:
- name: Checkout ballerina-spec
uses: actions/checkout@v2

- name: Clone ballerina-dev-website
run: git clone -b master --single-branch https://ballerina-bot:[email protected]/ballerina-platform/ballerina-dev-website.git

- name: Clone ballerina-prod-website
run: git clone https://ballerina-bot:[email protected]/ballerina-platform/ballerina-platform.github.io.git

- name: Delete spec directory from ballerina-dev-website
run: |
cd ballerina-dev-website
git pull origin master
git config --global user.email "[email protected]"
git config --global user.name "ballerina-bot"
if [ -d "spec/lang/${{ github.event.inputs.version }}" ]; then rm -Rf "spec/lang/${{ github.event.inputs.version }}"; else echo "${{ github.event.inputs.version }} directory not found"; fi
git add spec/lang
git commit --allow-empty -m "[Automated] Delete major release in master"
- name: Delete spec directory from ballerina-prod-website
run: |
cd ballerina-platform.github.io
git pull origin master
git config --global user.email "[email protected]"
git config --global user.name "ballerina-bot"
if [ -d "spec/lang/${{ github.event.inputs.version }}" ]; then rm -Rf "spec/lang/${{ github.event.inputs.version }}"; else echo "${{ github.event.inputs.version }} directory not found"; fi
git add spec/lang
git commit --allow-empty -m "[Automated] Delete major release in master"
- name: Push new changes to ballerina-dev-website
shell: bash
run: |
cd ballerina-dev-website
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}

- name: Push new changes to ballerina-prod-website
shell: bash
run: |
cd ballerina-platform.github.io
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}
44 changes: 42 additions & 2 deletions .github/workflows/draft_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ name: Sync draft spec with ballerina.io
on:
push:
tags:
- '*'
- 'v*-*-*'
workflow_dispatch:

jobs:
sync_draft_spec:
if: contains(github.ref_name, '-')
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}
Expand All @@ -20,6 +19,9 @@ jobs:
- name: Clone ballerina-dev-website
run: git clone -b master --single-branch https://ballerina-bot:[email protected]/ballerina-platform/ballerina-dev-website.git

- name: Clone ballerina-prod-website
run: git clone https://ballerina-bot:[email protected]/ballerina-platform/ballerina-platform.github.io.git

- name: Make new folder location in ballerina-dev-website
run: |
cd ballerina-dev-website/spec/lang/draft
Expand All @@ -30,11 +32,22 @@ jobs:
mkdir "${array[len-1]}"
echo "NEW_FOLDER=${array[len-1]}" >> $GITHUB_ENV
- name: Make new folder location in ballerina-prod-website
run: |
cd ballerina-platform.github.io/spec/lang/draft
if [ -d "${NEW_FOLDER}" ]; then rm -Rf "${NEW_FOLDER}"; fi
mkdir "${NEW_FOLDER}"
- name: Update the latest to new url in ballerina-dev-website
run: |
cd ballerina-dev-website/spec/lang/draft/latest
echo -e "---\nredirect_to: /spec/lang/draft/$NEW_FOLDER/\n---" > index.md
- name: Update the latest to new url in ballerina-prod-website
run: |
cd ballerina-platform.github.io/spec/lang/draft/latest
echo -e "---\nredirect_to: /spec/lang/draft/$NEW_FOLDER/\n---" > index.md
- name: Install xsltproc
run: sudo apt-get install -y xsltproc

Expand All @@ -48,9 +61,15 @@ jobs:
- name: Copy new spec to ballerina-dev-website
run: cp -r lang/build/* ballerina-dev-website/spec/lang/draft/$NEW_FOLDER

- name: Copy new spec to ballerina-prod-website
run: cp -r lang/build/* ballerina-platform.github.io/spec/lang/draft/$NEW_FOLDER

- name: Update the list of draft specs in ballerina-dev-website
run: python3 .github/scripts/append.py ballerina-dev-website/_data/draft_spec.json $NEW_FOLDER

- name: Update the list of draft specs in ballerina-prod-website
run: python3 .github/scripts/append.py ballerina-platform.github.io/_data/draft_spec.json $NEW_FOLDER

- name: Sync ballerina-spec with ballerina-dev-website
run: |
cd ballerina-dev-website
Expand All @@ -62,6 +81,18 @@ jobs:
git add _data/draft_spec.json
git add spec/lang/draft/
git commit --allow-empty -m "[Automated] Sync new spec-tag with ballerina dev site"
- name: Sync ballerina-spec with ballerina-prod-website
run: |
cd ballerina-platform.github.io
git pull origin master
git config --global user.email "[email protected]"
git config --global user.name "ballerina-bot"
git add _data/draft_spec.json
git add spec/lang/draft/
git commit --allow-empty -m "[Automated] Sync new spec-tag with ballerina prod site"
- name: Push new changes to ballerina-dev-website
shell: bash
Expand All @@ -71,3 +102,12 @@ jobs:
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}

- name: Push new changes to ballerina-prod-website
shell: bash
run: |
cd ballerina-platform.github.io
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
bin/hub push
env:
GITHUB_TOKEN: ${{ secrets.BAL_BOT_PAT }}
5 changes: 3 additions & 2 deletions .github/workflows/master_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- master
paths-ignore:
- '.github/**'
- 'conformance/**'

jobs:
sync_master_spec:
Expand All @@ -18,7 +19,7 @@ jobs:
uses: actions/checkout@v2

- name: Clone ballerina-dev-website
run: git clone https://ballerina-bot:[email protected]/ballerina-platform/ballerina-dev-website.git
run: git clone -b master --single-branch https://ballerina-bot:[email protected]/ballerina-platform/ballerina-dev-website.git

- name: Clone ballerina-prod-website
run: git clone https://ballerina-bot:[email protected]/ballerina-platform/ballerina-platform.github.io.git
Expand All @@ -35,7 +36,7 @@ jobs:
- name: Sync spec in master with ballerina-dev-website
run: |
cd ballerina-dev-website
git pull origin dev
git pull origin master
git config --global user.email "[email protected]"
git config --global user.name "ballerina-bot"
Expand Down
Loading

0 comments on commit 9f334c9

Please sign in to comment.