Track semVer through environments #9344
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: Track semVer through environments | |
on: | |
schedule: | |
- cron: '0 */3 * * *' # run every 3 hours and on push | |
# push is only for merge tracking | |
push: | |
branches: | |
- develop | |
jobs: | |
get_versions: | |
name: Get semVer for environments | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
- name: 'Get Previous tag' | |
id: apiprevioustag | |
run: | | |
TAG=$(git for-each-ref --sort=-creatordate --count 1 --format="%(refname:short)" "refs/tags/") | |
echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
service_account_key: ${{ secrets.GCP_BUCKET_SA_KEY }} | |
export_default_credentials: true | |
- name: Use gcloud copy endpoints.json | |
run: gsutil cp gs://deployment-tracking/endpoints.json . | |
- shell: bash | |
run: | | |
endPoints='[{"env":"merge","endpoint":"null"}, | |
{"env":"dev","endpoint":"https://jade.datarepo-dev.broadinstitute.org/configuration"}, | |
{"env":"alpha","endpoint":"https://data.alpha.envs-terra.bio/configuration"}, | |
{"env":"staging","endpoint":"https://data.staging.envs-terra.bio/configuration"}, | |
{"env":"production","endpoint":"https://data.terra.bio/configuration"}]' | |
date=$(date +%Y-%m-%d\ %H:%M:%S) | |
for row in $(echo "${endPoints}" | jq -r '.[] | @base64'); do | |
_jq() { | |
echo ${row} | base64 --decode | jq -r ${1} | |
} | |
env=$(_jq '.env') | |
if [ $env == "merge" ] | |
then | |
semVer="${{ steps.apiprevioustag.outputs.tag }}-SNAPSHOT" | |
else | |
semVer=$(curl -s $(_jq '.endpoint') | jq -r '.semVer') | |
fi | |
cat <<< $(jq --arg env "$env" \ | |
--arg date "$date" \ | |
--arg semVer "$semVer" \ | |
'.data += [{"env": "'"$env"'", "date": "'"$date"'", "semVer": "'"$semVer"'"}]' endpoints.json) \ | |
> endpoints.json | |
done | |
- name: Use gcloud copy to upload new endpoints.json to bucket | |
run: gsutil cp endpoints.json gs://deployment-tracking/endpoints.json | |
- name: Print uploaded file | |
run: cat endpoints.json |