This commit is contained in:
parent
d81af99e36
commit
33e1552ce1
56
.github/workflows/main.yml
vendored
56
.github/workflows/main.yml
vendored
@ -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
|
- name: Install doctl
|
||||||
id: task-def
|
uses: digitalocean/action-doctl@v2
|
||||||
uses: aws-actions/amazon-ecs-render-task-definition@v1
|
|
||||||
with:
|
with:
|
||||||
task-definition: task-definition.json
|
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
|
||||||
container-name: "prepbot"
|
|
||||||
image: ${{ steps.build-image.outputs.image }}
|
|
||||||
|
|
||||||
- name: Deploy Amazon ECS task definition
|
- name: Login to DigitalOcean Container Registry with short-lived credentials
|
||||||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
|
run: doctl registry login --expiry-seconds 600
|
||||||
with:
|
|
||||||
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
- name: Push image to DigitalOcean Container Registry
|
||||||
service: "prepbot"
|
run: docker push registry.digitalocean.com/djpianalto/prepbot
|
||||||
cluster: "discord-bots"
|
|
||||||
wait-for-service-stability: true
|
- 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
|
||||||
|
|||||||
31
deployment.yml
Normal file
31
deployment.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: prepbot
|
||||||
|
namespace: default
|
||||||
|
labels:
|
||||||
|
app: prepbot
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: prepbot
|
||||||
|
strategy:
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 1
|
||||||
|
minReadySeconds: 120
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: prepbot
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: prepbot
|
||||||
|
image: <IMAGE>
|
||||||
|
env:
|
||||||
|
- name: DISCORD_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: prepbot
|
||||||
|
key: discord_token
|
||||||
Loading…
x
Reference in New Issue
Block a user