-
Notifications
You must be signed in to change notification settings - Fork 3
72 lines (65 loc) · 1.86 KB
/
deploy-staging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Deploy Staging
on:
push:
branches: [ main ]
paths-ignore:
- 'doc/**'
- 'README.md'
permissions:
contents: read
pull-requests: write
jobs:
build-assets:
name: Compile and clean assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Compile assets
uses: ./.github/actions/compile-assets
with:
rails_env: staging
save_cache: true
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: staging-assets
path: public/assets
deploy:
name: Deploy to staging
runs-on: ubuntu-latest
needs: build-assets
environment: staging
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Download assets
uses: actions/download-artifact@v4
with:
name: staging-assets
path: public/assets
- name: Terraform apply
uses: dflook/terraform-apply@v1
env:
TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
TERRAFORM_PRE_RUN: |
apt-get update
apt-get install -y zip
with:
path: terraform
var_file: terraform/staging.tfvars
backend_config: >
access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
key=terraform.tfstate.staging
- name: Save app zip for debugging
if: failure()
uses: actions/upload-artifact@v4
with:
name: app-src-apply
path: terraform/dist/src.zip
compression-level: 0
retention-days: 1