add github action #22
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: Build | |
on: | |
pull_request: | |
branches: | |
- develop | |
- master | |
push: | |
branches: | |
- develop | |
- master | |
- feature/add_github_action | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Install Terraform CLI | |
uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: 1.x # Specify the Terraform version if needed | |
cli_config_credentials_token: ${{ secrets.HETZNER_CLOUD_TOKEN }} | |
- name: List Workspace Contents | |
run: ls -R ${{ github.workspace }} | |
- name: Create .ssh Directory | |
run: mkdir -p ${{ github.workspace }} | |
# - name: Upload secure file | |
# uses: actions/upload-artifact@v2 | |
# with: | |
# name: hcloud_terraform_id_rsa | |
# path: ${{ github.workspace }} | |
- name: Download secure file | |
uses: actions/download-artifact@v2 | |
with: | |
name: hcloud_terraform_id_rsa | |
path: ${{ github.workspace }}/.ssh | |
- name: Deploy Server | |
run: | | |
terraform init | |
terraform plan | |
terraform apply -auto-approve | |
env: | |
TF_VAR_hcloud_api_token: ${{ secrets.HETZNER_CLOUD_TOKEN }} | |
TF_VAR_ssh_private_key_path: ${{ steps.privateKey.outputs.artifactPath }} | |
TF_VAR_azure_devops_pat: ${{ secrets.AZURE_PAT }} | |
TF_VAR_ephemeral_password: ${{ secrets.EPHEMERAL_PASSWORD }} |