kopia lustrzana https://github.com/snarfed/bridgy-fed
circle: merge deploy back into main config
evidently multiple configs require GitHub App login, and I'm currently on GitHub OAuth https://circleci.com/docs/set-up-multiple-configuration-files-for-a-project/ https://circleci.com/docs/github-integration/ for #1089pull/1187/head
rodzic
c43df175be
commit
dc3e65170a
|
@ -6,6 +6,12 @@
|
|||
# https://circleci.com/docs/2.1/sample-config/
|
||||
version: 2.1
|
||||
|
||||
parameters:
|
||||
service:
|
||||
type: enum
|
||||
enum: ["app", "router", "atproto_hub", "default"]
|
||||
default: "default"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
|
@ -14,9 +20,6 @@ jobs:
|
|||
steps:
|
||||
- checkout
|
||||
|
||||
- restore_cache:
|
||||
key: venv-7-{{ .Branch }}-{{ checksum "requirements.txt" }}
|
||||
|
||||
- run:
|
||||
name: Base dependencies
|
||||
command: |
|
||||
|
@ -26,6 +29,24 @@ jobs:
|
|||
sudo apt-get update
|
||||
sudo apt-get install -y apt-transport-https ca-certificates gnupg google-cloud-sdk google-cloud-cli-firestore-emulator default-jre
|
||||
|
||||
- when:
|
||||
condition:
|
||||
equal: [ default, << pipeline.parameters.service >> ]
|
||||
|
||||
# I could get rid of "default" with eg pipeline.trigger_source, if it
|
||||
# distinguished manual from push, but I can't tell that it does.
|
||||
# https://circleci.com/docs/pipeline-variables/#pipeline-values
|
||||
#
|
||||
# pipeline.trigger_parameters.circleci.trigger_type looks promising!
|
||||
# https://stackoverflow.com/questions/75616644/how-to-detect-whether-a-circleci-pipeline-build-was-manually-triggered#comment133409450_75616644
|
||||
#
|
||||
# ...but it's only available to GitHub App logins, and I'm on Github OAuth :(
|
||||
# https://circleci.com/docs/github-integration/
|
||||
|
||||
steps:
|
||||
- restore_cache:
|
||||
key: venv-7-{{ .Branch }}-{{ checksum "requirements.txt" }}
|
||||
|
||||
- run:
|
||||
name: Python dependencies
|
||||
command: |
|
||||
|
@ -35,7 +56,6 @@ jobs:
|
|||
pip uninstall -y arroba dag-json granary lexrpc oauth-dropins
|
||||
pip install -U -r requirements.txt
|
||||
pip install coverage coveralls
|
||||
|
||||
ln -sf `pyenv prefix`/lib/python3.11/site-packages/oauth_dropins/fonts oauth_dropins_fonts
|
||||
ln -sf `pyenv prefix`/lib/python3.11/site-packages/oauth_dropins/static oauth_dropins_static
|
||||
|
||||
|
@ -53,27 +73,6 @@ jobs:
|
|||
# https://flake8.pycqa.org/en/latest/user/options.html#cmdoption-flake8-select
|
||||
flake8 --select=F811 tests/test_*.py
|
||||
|
||||
# only runs if all previous steps succeed, including tests
|
||||
# https://circleci.com/docs/configuration-reference/#the-when-attribute
|
||||
- run:
|
||||
name: Deploy
|
||||
command: |
|
||||
echo $CIRCLE_BRANCH
|
||||
if [ $CIRCLE_BRANCH = "main" ]; then
|
||||
echo $FLASK_SECRET_KEY > flask_secret_key
|
||||
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
|
||||
gcloud -q app deploy --no-cache --project bridgy-federated app.yaml index.yaml queue.yaml
|
||||
|
||||
# can't deploy router here yet because we need the limited_domains
|
||||
# file. next step would be to put it into a circle env var.
|
||||
#
|
||||
# WHEN WE DO, we have to do it in a separate gcloud command
|
||||
# because Flex services don't support --no-cache, but we need it
|
||||
# for the default service
|
||||
# https://issuetracker.google.com/issues/347268867
|
||||
# gcloud -q app deploy --project bridgy-federated router.yaml
|
||||
fi
|
||||
|
||||
- save_cache:
|
||||
key: venv-7-{{ .Branch }}-{{ checksum "requirements.txt" }}
|
||||
paths:
|
||||
|
@ -85,5 +84,27 @@ jobs:
|
|||
# - /usr/lib/google-cloud-sdk
|
||||
# - /usr/lib/jvm/java-11-openjdk-amd64
|
||||
|
||||
- run:
|
||||
name: Deploy
|
||||
command: |
|
||||
echo $CIRCLE_BRANCH
|
||||
if [ $CIRCLE_BRANCH = "main" ]; then
|
||||
echo $FLASK_SECRET_KEY > flask_secret_key
|
||||
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
|
||||
|
||||
service='<< pipeline.parameters.service >>'
|
||||
if [[ $service == 'default' ]]; then
|
||||
service='app'
|
||||
fi
|
||||
# Flex services don't support --no-cache, but we need it
|
||||
# for the default service.
|
||||
# https://issuetracker.google.com/issues/347268867
|
||||
if [[ $service == 'app' ]]; then
|
||||
nocache = '--no-cache'
|
||||
fi
|
||||
echo gcloud -q app deploy $nocache --project bridgy-federated << pipeline.parameters.service >>.yaml index.yaml queue.yaml
|
||||
fi
|
||||
|
||||
|
||||
- store_artifacts:
|
||||
path: /tmp/coverage_html
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
# Deploy pipeline.
|
||||
#
|
||||
# CircleCI automatically reads this file from our repo and uses it for
|
||||
# configuration. Docs:
|
||||
# https://circleci.com/docs/2.1/configuration-reference/
|
||||
# https://circleci.com/docs/2.1/sample-config/
|
||||
version: 2.1
|
||||
|
||||
parameters:
|
||||
service:
|
||||
type: enum
|
||||
enum: ["app", "router", "atproto_hub"]
|
||||
default: "router"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
# - image: cimg/python:3.11
|
||||
- image: google/cloud-sdk
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
# - run:
|
||||
# name: Install gcloud
|
||||
# command: |
|
||||
# # google-cloud-sdk: https://cloud.google.com/sdk/docs/install#deb
|
||||
# echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
|
||||
# curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y apt-transport-https ca-certificates gnupg google-cloud-sdk
|
||||
|
||||
- run:
|
||||
name: Deploy
|
||||
command: |
|
||||
echo $FLASK_SECRET_KEY > flask_secret_key
|
||||
echo $GCLOUD_SERVICE_KEY | gcloud auth activate-service-account --key-file=-
|
||||
if [[ '<< pipeline.parameters.service >>' == 'app' ]]; then
|
||||
nocache = '--no-cache'
|
||||
fi
|
||||
echo gcloud -q app deploy $nocache --project bridgy-federated << pipeline.parameters.service >>.yaml index.yaml queue.yaml
|
Ładowanie…
Reference in New Issue