# Setting Up Github Action Workflow

In Github go to Actions Tab and choose to set up a workflow yourself.

Our GitHub Action workflow automates the creation and destruction of AWS infrastructure using Terraform. It consists of two jobs, one for applying the Terraform configuration and the other for destroying it. The apply job checks out the code, sets up Terraform with the necessary credentials, runs `terraform init` and `terraform plan`, and applies the configuration with `terraform apply`. It also saves the Terraform state as an artifact. The destroy job checks out the code, sets up Terraform with the necessary credentials, downloads the previously saved Terraform state, runs `terraform init`, and destroys the infrastructure with `terraform destroy` if the user has prompted for destruction. Finally, it saves the Terraform state again as an artifact. The user can trigger this workflow manually and respond to a prompt to destroy the infrastructure.

In the code, `workflow_dispatch` event is used to trigger the `apply` job when the workflow is manually executed. When the workflow is triggered, it prompts the user with a message asking if they want to destroy the infrastructure, with the default option set to "no". If the user enters "yes", the `destroy` job will be executed.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rishaws-projects.gitbook.io/devops-project/setup-ci-cd/setting-up-github-action-workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
