This repository was archived by the owner on Feb 9, 2025. It is now read-only.
chore(deps): update grafana/promtail docker tag to v2.9.9 #46
Workflow file for this run
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 to production' | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
permissions: | |
contents: read | |
jobs: | |
terraform: | |
name: 'Create infrastructure' | |
runs-on: ubuntu-22.04 | |
environment: production | |
defaults: | |
run: | |
shell: bash | |
steps: | |
# Checkout the repository to the GitHub Actions runner | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token | |
- name: Setup Terraform | |
uses: hashicorp/[email protected] | |
with: | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. | |
- name: Terraform Init | |
run: terraform init | |
working-directory: ./infrastructure | |
# Checks that all Terraform configuration files adhere to a canonical format | |
- name: Terraform Format | |
run: terraform fmt -check | |
working-directory: ./infrastructure | |
# Generates an execution plan for Terraform | |
- name: Terraform Plan | |
run: terraform plan -input=false | |
working-directory: ./infrastructure | |
env: | |
TF_VAR_hcloud_token: ${{ secrets.TF_VAR_HCLOUD_TOKEN }} | |
# On push to "main", build or change infrastructure according to Terraform configuration files | |
# Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks | |
- name: Terraform Apply | |
working-directory: ./infrastructure | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
run: terraform apply -auto-approve -input=false | |
env: | |
TF_VAR_hcloud_token: ${{ secrets.TF_VAR_HCLOUD_TOKEN }} | |
ansible: | |
name: 'Deploy Services' | |
needs: terraform | |
runs-on: ubuntu-22.04 | |
environment: production | |
defaults: | |
run: | |
working-directory: ./services | |
env: | |
SSH_AUTH_SOCK: /tmp/ssh_agent.sock | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create SSH private key file and set permissions | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
run: | | |
mkdir ~/.ssh | |
chmod 700 ~/.ssh | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 | |
chmod 400 ~/.ssh/id_ed25519 | |
- name: Start SSH agent | |
run: ssh-agent -a $SSH_AUTH_SOCK > /dev/null | |
- name: Add private key to SSH agent | |
run: ssh-add | |
- name: Get VPS public key and set permissions for known_hosts | |
run: | | |
ssh-keyscan foss.rizexor.com >> ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
- name: Install dependencies | |
run: ansible-galaxy install -r roles/requirements.yml | |
- name: Create vault password file | |
env: | |
VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} | |
run: echo "$VAULT_PASSWORD" > .env | |
- name: Deploy services | |
run: ansible-playbook main.yml |