forked from DeSci-md/automating-metadata-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
154 additions
and
155 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,159 +1,158 @@ | ||
# build.yml | ||
on: | ||
# pull_request: | ||
# paths: | ||
# - desci-server/** | ||
push: | ||
paths: | ||
- .github/workflows/** | ||
- desci-server/** | ||
- desci-contracts/** | ||
- Dockerfile | ||
branches: # array of glob patterns matching against refs/heads. Optional; defaults to all | ||
- main # triggers on pushes that contain changes | ||
- develop | ||
|
||
name: Build automating-metadata | ||
|
||
# pull_request: | ||
# paths: | ||
# - desci-server/** | ||
push: | ||
paths: | ||
- .github/workflows/** | ||
- desci-server/** | ||
- desci-contracts/** | ||
- Dockerfile | ||
branches: # array of glob patterns matching against refs/heads. Optional; defaults to all | ||
- main # triggers on pushes that contain changes | ||
- develop | ||
|
||
name: | ||
Build automating-metadata | ||
|
||
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html | ||
env: | ||
AWS_DEFAULT_REGION: us-east-2 | ||
AWS_DEFAULT_OUTPUT: json | ||
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
CONTAINER_IMAGE: automating-metadata | ||
DOCKER_BUILDKIT: 1 | ||
|
||
jobs: | ||
build-and-push-images: | ||
# we build and push for every commit, even if tests pass, that way when tests pass deployment is short (run test + build in parallel) | ||
name: Build and push images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hashicorp/setup-terraform@v1 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# Add steps here like linting, testing, minification, etc. | ||
- id: install-aws-cli | ||
uses: unfor19/install-aws-cli-action@v1 | ||
with: | ||
version: 1 | ||
|
||
- uses: prepor/action-aws-iam-authenticator@master | ||
- run: aws-iam-authenticator version | ||
|
||
- name: Install Kubectl | ||
run: | | ||
#$(curl -Ls https://dl.k8s.io/release/stable.txt) | ||
version=v1.23.6 | ||
echo "using kubectl@$version" | ||
curl -sLO "https://dl.k8s.io/release/$version/bin/linux/amd64/kubectl" -o kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin | ||
mkdir $HOME/.kube | ||
sudo apt-get update | ||
sudo apt-get install less | ||
echo ${{ secrets.KUBE_CONFIG_DATA }} | base64 --decode > $HOME/.kube/config | ||
aws sts get-caller-identity | ||
- name: Build and tag the image (DEV) | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
# Build and tag the image | ||
docker build \ | ||
-t $CONTAINER_IMAGE-dev:${{ github.sha }} \ | ||
-t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev \ | ||
. | ||
- name: Build and tag the image (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
# Build and tag the image | ||
docker build \ | ||
-t $CONTAINER_IMAGE-prod:${{ github.sha }} \ | ||
-t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod \ | ||
. | ||
- name: Push (DEV) | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
# Push image to AWS ECR | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker tag $CONTAINER_IMAGE-dev:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} | ||
- name: Push (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
# Push image to AWS ECR | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker tag $CONTAINER_IMAGE-prod:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} | ||
deploy: | ||
name: Deploy automating-metadata | ||
needs: | ||
- build-and-push-images | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hashicorp/setup-terraform@v1 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
env: | ||
AWS_DEFAULT_REGION: us-east-2 | ||
AWS_DEFAULT_OUTPUT: json | ||
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
CONTAINER_IMAGE: automating-metadata | ||
DOCKER_BUILDKIT: 1 | ||
|
||
jobs: | ||
build-and-push-images: | ||
# we build and push for every commit, even if tests pass, that way when tests pass deployment is short (run test + build in parallel) | ||
name: Build and push images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hashicorp/setup-terraform@v1 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
# Add steps here like linting, testing, minification, etc. | ||
- id: install-aws-cli | ||
uses: unfor19/install-aws-cli-action@v1 | ||
with: | ||
version: 1 | ||
|
||
- uses: prepor/action-aws-iam-authenticator@master | ||
- run: aws-iam-authenticator version | ||
|
||
- name: Install Kubectl | ||
run: | | ||
#$(curl -Ls https://dl.k8s.io/release/stable.txt) | ||
version=v1.23.6 | ||
echo "using kubectl@$version" | ||
curl -sLO "https://dl.k8s.io/release/$version/bin/linux/amd64/kubectl" -o kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin | ||
mkdir $HOME/.kube | ||
sudo apt-get update | ||
sudo apt-get install less | ||
echo ${{ secrets.KUBE_CONFIG_DATA }} | base64 --decode > $HOME/.kube/config | ||
aws sts get-caller-identity | ||
- name: Build and tag the image (DEV) | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
# Build and tag the image | ||
docker build \ | ||
-t $CONTAINER_IMAGE-dev:${{ github.sha }} \ | ||
-t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev \ | ||
. | ||
- name: Build and tag the image (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
# Build and tag the image | ||
docker build \ | ||
-t $CONTAINER_IMAGE-prod:${{ github.sha }} \ | ||
-t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod \ | ||
. | ||
- name: Push (DEV) | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
# Push image to AWS ECR | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker tag $CONTAINER_IMAGE-dev:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} | ||
- name: Push (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
# Push image to AWS ECR | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker tag $CONTAINER_IMAGE-prod:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} | ||
deploy: | ||
name: Deploy automating-metadata | ||
needs: | ||
- build-and-push-images | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hashicorp/setup-terraform@v1 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# Add steps here like linting, testing, minification, etc. | ||
- id: install-aws-cli | ||
uses: unfor19/install-aws-cli-action@v1 | ||
with: | ||
version: 1 | ||
|
||
- uses: prepor/action-aws-iam-authenticator@master | ||
- run: aws-iam-authenticator version | ||
|
||
- name: Install Kubectl | ||
run: | | ||
#$(curl -Ls https://dl.k8s.io/release/stable.txt) | ||
version=v1.23.6 | ||
echo "using kubectl@$version" | ||
curl -sLO "https://dl.k8s.io/release/$version/bin/linux/amd64/kubectl" -o kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin | ||
mkdir $HOME/.kube | ||
sudo apt-get update | ||
sudo apt-get install less | ||
echo ${{ secrets.KUBE_CONFIG_DATA }} | base64 --decode > $HOME/.kube/config | ||
aws sts get-caller-identity | ||
- name: Deploy to EKS (DEV) | ||
# uses: steebchen/kubectl@v2.0.0 | ||
if: github.ref == 'refs/heads/develop' | ||
run: | # defaults to latest kubectl binary version | ||
kubectl apply -f desci-server/kubernetes/deployment_dev.yaml | ||
kubectl set image deployment/desci-server-dev desci-server-dev=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} --record | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker pull $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} | ||
docker tag $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:latest | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:latest | ||
- name: Deploy to EKS (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | # defaults to latest kubectl binary version | ||
kubectl apply -f desci-server/kubernetes/deployment_prod.yaml | ||
kubectl set image deployment/desci-server desci-server=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} --record | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker pull $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} | ||
docker tag $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:latest | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:latest | ||
- name: Verify EKS Deployment (DEV) | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
kubectl rollout status deployment/automating-metadata-dev | ||
- name: Verify EKS Deployment (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
kubectl rollout status deployment/automating-metadata-prod | ||
- id: install-aws-cli | ||
uses: unfor19/install-aws-cli-action@v1 | ||
with: | ||
version: 1 | ||
|
||
- uses: prepor/action-aws-iam-authenticator@master | ||
- run: aws-iam-authenticator version | ||
|
||
- name: Install Kubectl | ||
run: | | ||
#$(curl -Ls https://dl.k8s.io/release/stable.txt) | ||
version=v1.23.6 | ||
echo "using kubectl@$version" | ||
curl -sLO "https://dl.k8s.io/release/$version/bin/linux/amd64/kubectl" -o kubectl | ||
chmod +x kubectl | ||
mv kubectl /usr/local/bin | ||
mkdir $HOME/.kube | ||
sudo apt-get update | ||
sudo apt-get install less | ||
echo ${{ secrets.KUBE_CONFIG_DATA }} | base64 --decode > $HOME/.kube/config | ||
aws sts get-caller-identity | ||
- name: Deploy to EKS (DEV) | ||
# uses: steebchen/kubectl@v2.0.0 | ||
if: github.ref == 'refs/heads/develop' | ||
run: | # defaults to latest kubectl binary version | ||
kubectl apply -f desci-server/kubernetes/deployment_dev.yaml | ||
kubectl set image deployment/desci-server-dev desci-server-dev=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} --record | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker pull $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} | ||
docker tag $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:latest | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-dev:latest | ||
- name: Deploy to EKS (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | # defaults to latest kubectl binary version | ||
kubectl apply -f desci-server/kubernetes/deployment_prod.yaml | ||
kubectl set image deployment/desci-server desci-server=$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} --record | ||
aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com | ||
docker pull $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} | ||
docker tag $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:${{ github.sha }} $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:latest | ||
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$CONTAINER_IMAGE-prod:latest | ||
- name: Verify EKS Deployment (DEV) | ||
if: github.ref == 'refs/heads/develop' | ||
run: | | ||
kubectl rollout status deployment/automating-metadata-dev | ||
- name: Verify EKS Deployment (PROD) | ||
if: github.ref == 'refs/heads/main' | ||
run: | | ||
kubectl rollout status deployment/automating-metadata-prod |