|
|
|
@ -17,46 +17,34 @@ jobs:
|
|
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
|
|
|
|
- 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: us-east-1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Login to Amazon ECR
|
|
|
|
|
|
|
|
id: login-ecr
|
|
|
|
|
|
|
|
uses: aws-actions/amazon-ecr-login@v1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Get Version
|
|
|
|
- name: Get Version
|
|
|
|
id: get_version
|
|
|
|
id: get_version
|
|
|
|
uses: battila7/get-version-action@v2.0.0
|
|
|
|
uses: battila7/get-version-action@v2.0.0
|
|
|
|
|
|
|
|
|
|
|
|
- name: Build, tag, and push image to Amazon ECR
|
|
|
|
- name: Build container image
|
|
|
|
id: build-image
|
|
|
|
|
|
|
|
env:
|
|
|
|
env:
|
|
|
|
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
|
|
|
|
|
|
ECR_REPOSITORY: prepbot
|
|
|
|
|
|
|
|
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }}
|
|
|
|
IMAGE_TAG: ${{ steps.get_version.outputs.version-without-v }}
|
|
|
|
run: |
|
|
|
|
run: docker build -t registry.digitalocean.com/djpianalto/prepbot:$IMAGE_TAG .
|
|
|
|
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
|
|
|
|
|
|
|
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
|
|
|
|
|
|
|
|
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
|
|
|
|
|
|
|
|
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
|
|
|
|
|
|
|
|
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Fill in the new image ID in the Amazon ECS task definition
|
|
|
|
|
|
|
|
id: task-def
|
|
|
|
|
|
|
|
uses: aws-actions/amazon-ecs-render-task-definition@v1
|
|
|
|
|
|
|
|
with:
|
|
|
|
|
|
|
|
task-definition: task-definition.json
|
|
|
|
|
|
|
|
container-name: "prepbot"
|
|
|
|
|
|
|
|
image: ${{ steps.build-image.outputs.image }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy Amazon ECS task definition
|
|
|
|
- name: Install doctl
|
|
|
|
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
|
|
|
|
uses: digitalocean/action-doctl@v2
|
|
|
|
with:
|
|
|
|
with:
|
|
|
|
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
|
|
|
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
|
|
|
|
service: "prepbot"
|
|
|
|
|
|
|
|
cluster: "discord-bots"
|
|
|
|
- name: Login to DigitalOcean Container Registry with short-lived credentials
|
|
|
|
wait-for-service-stability: true
|
|
|
|
run: doctl registry login --expiry-seconds 600
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Push image to DigitalOcean Container Registry
|
|
|
|
|
|
|
|
run: docker push registry.digitalocean.com/djpianalto/prepbot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Update deployment file
|
|
|
|
|
|
|
|
run: TAG=${{ steps.get_version.outputs.version-without-v }} && sed -i 's|<IMAGE>|registry.digitalocean.com/djpianalto/prepbot:'${TAG}'|' $GITHUB_WORKSPACE/deployment.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Save DigitalOcean kubeconfig with short-lived credentials
|
|
|
|
|
|
|
|
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 discord-bots
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy to DigitalOcean Kubernetes
|
|
|
|
|
|
|
|
run: kubectl apply -f $GITHUB_WORKSPACE/deployment.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Verify deployment
|
|
|
|
|
|
|
|
run: kubectl rollout status deployment/prepbot
|
|
|
|
|