generated from DFE-Digital/govuk-dotnet-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
41 lines (35 loc) · 1.24 KB
/
backup-contentful.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
name: Backup Contentful
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # This will run every day at midnight UTC
jobs:
backup:
name: 'Backup Contentful'
runs-on: ubuntu-latest
env:
ENVID: master
SPACE: ${{ secrets.TF_VAR_CPD_SPACE_ID }}
MANAGEMENT_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
steps:
- name: Run backup container
run: docker run --rm -e token=$MANAGEMENT_TOKEN -e space=$SPACE -e envid=$ENVID -v $PWD:/opt/backup ghcr.io/dfe-digital/contentful-space-export:master
- name: Checkout destination repository
uses: actions/checkout@v2
with:
repository: DFE-Digital/childrens-social-care-cpd-contentful-backup
token: ${{ secrets.BACKUP_REPO_PAT }}
path: backup
- name: Copy output and commit
run: |
cp `find *.json` backup/prod-contentful-backup-output.json
cd backup
if git diff --exit-code --quiet; then
echo "No changes detected, skipping push"
else
git config user.name "DfE Robot"
git config user.email ${{ secrets.CONTENTFUL_BACKUP_EMAIL }}
git add prod-contentful-backup-output.json
git commit -m "Upload new backup"
git push
fi