Skip to content

Commit

Permalink
Switch to reusable workflows (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov authored Feb 10, 2022
1 parent 930d057 commit 1512dfa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 206 deletions.
65 changes: 19 additions & 46 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,55 +63,28 @@ jobs:
name: codecov-integration
- name: Build Docker image
run: make docker_build
env:
IMAGE_TAG: latest
- name: Upload image artifact
uses: neuro-inc/[email protected]
with:
image: platformserviceaccountsapi
token: ${{ secrets.GITHUB_TOKEN }}
deploy_dev:
name: Deploy to dev
environment: dev
runs-on: ubuntu-latest

release:
name: Create release
needs: test
concurrency: deploy_dev
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_REGION: us-east-1
CLUSTER_NAME: aws-dev
HELM_ENV: dev
IMAGE_REGISTRY: aws
IMAGE_TAG: ${{ github.sha }}
steps:
- name: Checkout commit
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install python
uses: actions/setup-python@v2
with:
python-version: 3.9.9
- name: Install Helm
uses: azure/[email protected]
with:
version: v3.7.0
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to AWS ECR
uses: aws-actions/amazon-ecr-login@v1
- name: Build image
run: make docker_build
- name: Push image to registry
run: |
make docker_push
IMAGE_TAG=latest make docker_push
- name: Update kube config
run: aws eks --region $AWS_REGION update-kubeconfig --name $CLUSTER_NAME
- name: Deploy to kubernetes
run: make helm_deploy
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
uses: neuro-inc/reuse/.github/workflows/[email protected]
with:
image: platformserviceaccountsapi
helm_charts: platform-service-accounts

deploy_dev:
name: Deploy on dev
needs: release
uses: neuro-inc/reuse/.github/workflows/[email protected]
with:
helm_charts: platform-service-accounts
version: ${{ needs.release.outputs.version }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
105 changes: 0 additions & 105 deletions .github/workflows/release.yml

This file was deleted.

26 changes: 14 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,24 @@ repos:
files: |
docs/spelling_wordlist.txt|
.gitignore
- repo: https://github.com/rhysd/actionlint
rev: v1.6.8
hooks:
- id: actionlint-docker
args:
- -ignore
- 'SC2155:'
- -ignore
- 'SC2086:'
- -ignore
- 'SC1004:'
# - repo: https://github.com/rhysd/actionlint
# rev: v1.6.8
# hooks:
# - id: actionlint-docker
# args:
# - -ignore
# - 'SC2155:'
# - -ignore
# - 'SC2086:'
# - -ignore
# - 'SC1004:'
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.10.2
hooks:
- id: check-github-actions
- id: check-github-workflows
ci:
skip:
- actionlint-docker
# - actionlint-docker
- check-github-actions
- check-github-workflows
45 changes: 2 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
AWS_REGION ?= us-east-1

GITHUB_OWNER ?= neuro-inc

IMAGE_TAG ?= latest

IMAGE_REPO_aws = $(AWS_ACCOUNT_ID).dkr.ecr.$(AWS_REGION).amazonaws.com
IMAGE_REPO_github = ghcr.io/$(GITHUB_OWNER)

IMAGE_REGISTRY ?= aws

IMAGE_NAME = platformserviceaccountsapi
IMAGE_REPO_BASE = $(IMAGE_REPO_$(IMAGE_REGISTRY))
IMAGE_REPO = $(IMAGE_REPO_BASE)/$(IMAGE_NAME)

HELM_ENV ?= dev
HELM_CHART = platform-service-accounts
HELM_CHART_VERSION ?= 1.0.0
HELM_APP_VERSION ?= 1.0.0

PYTEST_FLAGS=


setup:
pip install -U pip
pip install -r requirements/test.txt
Expand All @@ -30,7 +9,7 @@ lint: format
mypy platform_service_accounts_api tests --show-error-codes

format:
ifdef CI_LINT_RUN
ifdef CI
pre-commit run --all-files --show-diff-on-failure
else
pre-commit run --all-files
Expand All @@ -45,24 +24,4 @@ test_integration:
docker_build:
pip install build
python -m build
docker build -t $(IMAGE_NAME):latest .

docker_push:
docker tag $(IMAGE_NAME):latest $(IMAGE_REPO):$(IMAGE_TAG)
docker push $(IMAGE_REPO):$(IMAGE_TAG)

helm_create_chart:
export IMAGE_REPO=$(IMAGE_REPO); \
export IMAGE_TAG=$(IMAGE_TAG); \
export CHART_VERSION=$(HELM_CHART_VERSION); \
export APP_VERSION=$(HELM_APP_VERSION); \
VALUES=$$(cat charts/$(HELM_CHART)/values.yaml | envsubst); \
echo "$$VALUES" > charts/$(HELM_CHART)/values.yaml; \
CHART=$$(cat charts/$(HELM_CHART)/Chart.yaml | envsubst); \
echo "$$CHART" > charts/$(HELM_CHART)/Chart.yaml

helm_deploy: helm_create_chart
helm dependency update charts/$(HELM_CHART)
helm upgrade $(HELM_CHART) charts/$(HELM_CHART) \
-f charts/$(HELM_CHART)/values-$(HELM_ENV).yaml \
--namespace platform --install --wait --timeout 600s
docker build -t platformserviceaccountsapi:latest .

0 comments on commit 1512dfa

Please sign in to comment.