Deploy #1
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: Deploy | |
# on: | |
# workflow_dispatch: | |
on: | |
workflow_run: | |
workflows: ["Test"] | |
types: | |
- completed | |
jobs: | |
deploy-base-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Log in to GHCR | |
run: echo "${{ secrets.REPO_ADMIN_GHCR_TOKEN }}" | docker login ghcr.io -u "${{ secrets.REPO_ADMIN_GH_USERNAME }}" --password-stdin | |
- name: Get base image tag and version | |
run: | | |
BASE_VERSION=$(cat ./assets/.BASE_VERSION) | |
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_ENV | |
BASE_IMG=ghcr.io/biosimulators/bio-check-base | |
echo "BASE_IMG=$BASE_IMG" >> $GITHUB_ENV | |
echo "Base Version: $BASE_VERSION" | |
echo "Base Tag: $BASE_IMG" | |
- name: Create gcloud config | |
run: | | |
echo "$BIOSIMULATIONS_GCLOUD_CONFIG" > ./assets/configs/.biosimulations.json | |
env: | |
BIOSIMULATIONS_GCLOUD_CONFIG: ${{ secrets.BIO_JSON_CONTENT }} | |
- name: Build base image | |
run: | | |
docker build --no-cache -f ./Dockerfile-base -t ${{ env.BASE_IMG }}:${{ env.BASE_VERSION }} . | |
- name: Deploy new base version to GHCR | |
run: | | |
docker push ${{ env.BASE_IMG }}:${{ env.BASE_VERSION }} | |
- name: Deploy new latest base version | |
run: | | |
docker tag ${{ env.BASE_IMG }}:${{ env.BASE_VERSION }} ${{ env.BASE_IMG }}:latest | |
docker push ${{ env.BASE_IMG }}:latest | |
get-microservice-versions: | |
needs: deploy-base-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 5: Extract API container version | |
- name: Extract API container version | |
id: extract_api_version | |
run: | | |
API_VERSION=$(python3 .github/parse_container_version.py api) | |
echo "API_VERSION=$API_VERSION" >> $GITHUB_ENV | |
echo "API Version: $API_VERSION" | |
# Step 6: Extract worker container version | |
- name: Extract worker container version | |
id: extract_worker_version | |
run: | | |
WORKER_VERSION=$(python3 .github/parse_container_version.py worker) | |
echo "WORKER_VERSION=$WORKER_VERSION" >> $GITHUB_ENV | |
echo "WORKER Version: $WORKER_VERSION" | |
# Step 7: Debug output of extracted versions | |
- name: Debug output of extracted versions | |
run: | | |
echo "API_VERSION=${{ env.API_VERSION }}" | |
echo "WORKER_VERSION=${{ env.WORKER_VERSION }}" | |
build-microservice-images: | |
needs: get-microservice-versions | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r assets/configs/requirements.github.txt | |
- name: Install Docker Compose | |
run: | | |
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
docker-compose --version # Check if Docker Compose is installed correctly | |
- name: Build Docker containers with Docker Compose | |
run: docker-compose build | |
- name: Authorize push script | |
run: chmod +x ./assets/scripts/push_image.sh | |
- name: Deploy API microservice container to GHCR | |
run: | | |
rm api/spec/openapi_3_1_0_generated.yaml | |
python3 api/openapi_spec.py | |
sudo rm -r api/__pycache__ | |
./assets/scripts/push_image.sh api ${{ env.API_VERSION }} | |
# STABLE CONTENT: | |
# - run: | | |
# rm compose_api/spec/openapi_3_1_0_generated.yaml | |
# python3 compose_api/openapi_spec.py | |
# sudo rm -r compose_api/__pycache__ | |
# ./assets/scripts/push_image.sh compose_api ${{ env.API_VERSION }} | |
env: | |
REPO_ADMIN_GH_USERNAME: ${{ secrets.REPO_ADMIN_GH_USERNAME }} | |
REPO_ADMIN_GHCR_TOKEN: ${{ secrets.REPO_ADMIN_GHCR_TOKEN }} | |
- name: Deploy worker microservice container to GHCR | |
run: | | |
sudo rm -r compose_api/__pycache__ | |
./assets/scripts/push_image.sh worker ${{ env.WORKER_VERSION }} | |
# STABLE CONTENT: | |
# run: | | |
# sudo rm -r compose_api/__pycache__ | |
# ./assets/scripts/push_image.sh compose_worker ${{ env.WORKER_VERSION }} | |
env: | |
REPO_ADMIN_GH_USERNAME: ${{ secrets.REPO_ADMIN_GH_USERNAME }} | |
REPO_ADMIN_GHCR_TOKEN: ${{ secrets.REPO_ADMIN_GHCR_TOKEN }} |