Last active
March 25, 2024 23:11
-
-
Save codebutler/866632927ae1fddfdb7b66a8721027e4 to your computer and use it in GitHub Desktop.
preevy + s3 + k8s
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
name: Teardown Preevy environment | |
on: | |
pull_request: | |
types: | |
- closed | |
permissions: | |
# Needed to authenticate with AWS | |
id-token: write | |
# Needed to read the docker-compose.yml file | |
contents: read | |
# Needed to write a PR comment with the environment URLs | |
pull-requests: write | |
jobs: | |
teardown: | |
timeout-minutes: 15 | |
environment: preevy | |
# allow a single job to run per PR | |
concurrency: preevy-${{ github.event.number }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: arn:aws:iam::xxxxxxxxx:role/github-action-role | |
role-duration-seconds: 1200 | |
- uses: actions/checkout@v3 | |
- name: Set up Kubectl | |
uses: azure/k8s-set-context@v1 | |
with: | |
kubeconfig: ${{ secrets.KUBECONFIG }} | |
- uses: livecycle/preevy-down-action@v1.4.0 | |
id: preevy | |
with: | |
profile-url: "${{ vars.PREEVY_PROFILE_URL }}" | |
docker-compose-yaml-paths: "./docker-compose.yml" | |
install: gh-release | |
args: "--debug" |
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
name: Deploy Preevy environment | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
permissions: | |
# Needed to authenticate with AWS | |
id-token: write | |
# Needed to read the docker-compose.yml file | |
contents: read | |
# Needed to write a PR comment with the environment URLs | |
pull-requests: write | |
jobs: | |
deploy: | |
timeout-minutes: 15 | |
environment: preevy | |
# allow a single job to run per PR | |
concurrency: preevy-${{ github.event.number }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: arn:aws:iam::xxxxxxxxx:role/github-action-role | |
role-duration-seconds: 1200 | |
- uses: actions/checkout@v3 | |
- name: Set up Kubectl | |
uses: azure/k8s-set-context@v1 | |
with: | |
# the entire ~/.kube/config file stored in GH action secrets | |
kubeconfig: ${{ secrets.KUBECONFIG }} | |
# this pod was manually created with: | |
# docker buildx create --driver kubernetes | |
- name: Find pod of existing kubernetes builder | |
id: find_pod | |
run: | | |
pod=$(kubectl get pods -o json | jq -r '.items[] | select(.spec.containers[].name == "buildkitd") | .metadata.name | limit(1;.)') | |
echo "pod=${pod}" >> $GITHUB_OUTPUT | |
- name: Configure buildx to use the existing kubernetes builder | |
id: buildx_setup | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: remote | |
endpoint: kube-pod://${{ steps.find_pod.outputs.pod }} | |
- uses: livecycle/preevy-up-action@v2.4.0 | |
id: preevy | |
with: | |
# this is an s3 url | |
profile-url: "${{ vars.PREEVY_PROFILE_URL }}" | |
args: "--builder ${{ steps.buildx_setup.outputs.name }} --debug" | |
docker-compose-yaml-paths: "./docker-compose.yml" | |
install: gh-release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment