update #10
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: CDKTF | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: pip install cdktf | |
- name: cdktf get | |
run: npx cdktf-cli get | |
- name: cdktf diff | |
run: npx cdktf-cli diff > /tmp/cdktf.diff.txt | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
ZONE_ID: ${{ secrets.ZONE_ID }} | |
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
S3_BUCKET: ${{ secrets.S3_BUCKET }} | |
- name: Read cdktf diff | |
id: diffresult | |
uses: jaywcjlove/github-action-read-file@main | |
with: | |
path: /tmp/cdktf.diff.txt | |
- name: Comment on pull request | |
uses: actions/github-script@v4 | |
if: github.event_name == 'pull_request' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const { owner, repo } = context.repo; | |
const { number } = context.issue; | |
const diff = context.steps.diffresult.outputs.content; | |
github.issues.createComment({ | |
owner, | |
repo, | |
issue_number: number, | |
body: `CDKTF Diff:\n\`\`\`${diff}\`\`\`` | |
}); | |
- name: cdktf apply | |
run: npx cdktf-cli apply --auto-approve | |
if: github.event_name == 'push' | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
ZONE_ID: ${{ secrets.ZONE_ID }} | |
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} | |
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }} | |
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }} | |
S3_BUCKET: ${{ secrets.S3_BUCKET }} |