-
Notifications
You must be signed in to change notification settings - Fork 2
49 lines (41 loc) · 1.64 KB
/
new-repo.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
name: Save repository info
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
save_repo_info:
name: Save repository info to .env file
if: >-
${{ !github.event.repository.is_template }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
- name: Override .env files with repository info
run: |
rm -rf apps/sanity/.env
rm -rf apps/storyblok/.env
touch apps/sanity/.env
touch apps/storyblok/.env
echo -e "\nREPO_PROD_BRANCH=\"main\"\nREPO_TYPE=\"github\"\nREPO_ID=${{ github.event.repository.id }}\nREPO_NAME=${{ github.repository }}" >> apps/sanity/.env
echo -e "\nREPO_PROD_BRANCH=\"main\"\nREPO_TYPE=\"github\"\nREPO_ID=${{ github.event.repository.id }}\nREPO_NAME=${{ github.repository }}" >> apps/storyblok/.env
- name: Remove unnecessary scripts
run: |
jq 'del(.scripts["pull-stories"])' apps/storyblok/package.json > apps/storyblok/package.json.tmp
mv apps/storyblok/package.json.tmp apps/storyblok/package.json
- name: Commit, push, and remove GitHub Actions workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.event.repository.owner.login }}@users.noreply.github.com"
rm -rf .github/workflows
git add .
git commit -m "Add repository info to .env and remove GitHub Actions workflows"
git push origin main