Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Naramsim
Copy link
Member

@Naramsim Naramsim commented May 2, 2020

This PR allows invoking in a conditional manner a new deploy job present in the PokeAPI/deploy CircleCI configuration. This job will automatically deploy the api-data data to our productive environment (pokeapi.co) or to a new staging environment. The job will be invoked only when the master or staging branches of this repository are pushed to. If the master is getting pushed then the master branch will be deployed in the productive environment. Viceversa, if the staging branch is pushed, then the staging branch will be deployed in the staging environment.

A more descriptive and general overview is detailed in this PokeAPI/pokeapi#488 PR.


This PR is linked to the following PRs:

When PokeAPI/deploy#10 will be merged we need to change .circleci/config.yml#38, updater/cmd.bash#33, updater/cmd.bash#36

This PR should be merged after PokeAPI/deploy#10

@Naramsim Naramsim added the wip Work in progress, don't merge label May 2, 2020
Copy link
Member

@phalt phalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work man, real good.

Copy link
Member

@sargunv sargunv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved assuming the present TODOs are taken care of before merging

if [ "${CIRCLE_BRANCH}" = 'master' ]; then # https://stackoverflow.com/a/2013589/3482533
~/.local/bin/ditto transform --base-url='https://pokeapi.co' --src-dir=data --dest-dir=_gen
elif [ "${CIRCLE_BRANCH}" = 'staging' ]; then
~/.local/bin/ditto transform --base-url='https://pokeapi-test-b6137.firebaseapp.com' --src-dir=data --dest-dir=_gen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming Bash 4 is available on the host, I'd organize this with something like this (untested):

also rename the file to .bash instead of .sh if you do this to make it obvious it uses bash syntax

#!/usr/bin/env bash

declare -A BRANCH_TO_URL=(
    ["master"]="https://pokeapi.co"
    ["staging"]="https://pokeapi-test-b6137.firebaseapp.com"
)

BASE_URL="${BRANCH_TO_URL[$CIRCLE_BRANCH]}"
~/.local/bin/ditto transform --base-url="$BASE_URL" --src-dir=data --dest-dir=_gen

@Naramsim Naramsim merged commit a7c7683 into master May 13, 2020
@Naramsim Naramsim deleted the staging branch May 13, 2020 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants