Added php-dependency-list #11
This file contains hidden or 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: "OpenTofu plan" | |
concurrency: tofu-ci | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
opentofu-plan: | |
name: "OpenTofu plan" | |
# This conditional acts as an access control list to prevent exposing | |
# secrets to untrusted pull requests. | |
if: | | |
github.event.issue.pull_request && | |
github.event.comment.body == '/plan' && | |
( | |
github.event.comment.user.login == 'Vinai' || | |
github.event.comment.user.login == 'sprankhub' | |
) | |
runs-on: ubuntu-latest | |
env: | |
TF_LOG: DEBUG | |
# Google Cloud Storage state backend | |
GOOGLE_APPLICATION_CREDENTIALS_DATA: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_DATA }} | |
GOOGLE_APPLICATION_CREDENTIALS: '/tmp/tf-google-application-credentials.json' | |
# GitHub provider | |
TF_VAR_app_node_id: ${{ secrets.TF_VAR_APP_NODE_ID }} | |
TF_VAR_github_app_id: ${{ secrets.GH_APP_ID }} | |
TF_VAR_github_app_installation_id: ${{ secrets.GH_APP_INSTALLATION_ID }} | |
TF_VAR_github_app_pem_file: ${{ secrets.GH_APP_PEM_FILE }} | |
steps: | |
- name: Write GCS credentials | |
run: echo $GOOGLE_APPLICATION_CREDENTIALS_DATA > $GOOGLE_APPLICATION_CREDENTIALS | |
- name: Get pull request ref | |
id: ref | |
uses: actions/github-script@v7 | |
with: | |
result-encoding: string | |
script: | | |
const { number } = context.issue; | |
return `refs/pull/${context.issue.number}/merge`; | |
- uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: "@${{ github.actor }} Starting OpenTofu plan ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
}) | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ steps.ref.outputs.result }} | |
- name: Setup OpenTofu | |
uses: opentofu/setup-opentofu@v1 | |
- name: OpenTofu init | |
id: init | |
run: tofu init | |
- name: OpenTofu plan | |
id: plan | |
run: tofu plan -no-color | |
continue-on-error: true | |
- uses: actions/github-script@v7 | |
env: | |
PLAN: "tofu\n${{ steps.plan.outputs.stdout }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const output = `#### OpenTofu Plan \`${{ steps.plan.outcome }}\` | |
<details><summary>Show Plan</summary> | |
\`\`\`\n | |
${process.env.PLAN} | |
\`\`\` | |
</details> | |
Issuer: @${{ github.actor }}, Action: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
- name: OpenTofu plan status | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 |