Skip to content

Commit 721421c

Browse files
authored
Add template install and update scripts (#193)
## Changes * Add download-and-install script * Add install-template script * Add update-template script * Add template-only-cd.yml workflow ## Context Based on similar scripts in template-infra and template-application-nextjs so that we don't have to manually apply changes to the test repos (e.g. platform-test-flask) every time there's a change to the template. For similar PR on nextjs see navapbc/template-application-nextjs#93
1 parent d3b2f28 commit 721421c

File tree

6 files changed

+101
-17
lines changed

6 files changed

+101
-17
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Template Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
# Only allow one workflow at a time to prevent race conditions when pushing changes to the project repo
10+
concurrency: template-only-cd
11+
12+
jobs:
13+
deploy:
14+
name: Deploy
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout template repo
18+
uses: actions/checkout@v3
19+
with:
20+
path: template-application-flask
21+
- name: Checkout project repo
22+
uses: actions/checkout@v3
23+
with:
24+
path: project-repo
25+
repository: navapbc/platform-test-flask
26+
token: ${{ secrets.PLATFORM_BOT_GITHUB_TOKEN }}
27+
28+
- name: Update application template
29+
working-directory: project-repo
30+
run: ../template-application-flask/template-only-bin/update-template.sh
31+
32+
- name: Push changes to project repo
33+
working-directory: project-repo
34+
run: |
35+
git config user.name nava-platform-bot
36+
git config user.email platform-admins@navapbc.com
37+
git add --all
38+
# Commit changes (if no changes then no-op)
39+
git diff-index --quiet HEAD || git commit -m "Template application deploy #${{ github.run_id }}"
40+
git push

.hadolint.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# List of settings and ignore or safelist findings for the hadolint scanner
2-
32
# For more information on any settings you can specify, see the actions' documentation here
43
# https://github.com/hadolint/hadolint#configure
54
failure-threshold: warning

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ The template application is intended to work with the infrastructure from [templ
1717

1818
## Installation
1919

20-
To get started using the template infrastructure on your project, install the template by cloning the template repository and copying the following folders/files to your repository:
21-
22-
```bash
23-
# fetch latest version of the template
24-
git clone --single-branch --branch main --depth 1 git@github.com:navapbc/template-application-flask.git
25-
26-
cp -r \
27-
template-application-flask/.github \
28-
template-application-flask/docs \
29-
template-application-flask/app \
30-
template-application-flask/docker-compose.yml \
31-
.
32-
33-
# clean up the template folder
34-
rm -fr template-application-flask
35-
```
20+
To get started using the template application on your project:
21+
22+
1. Run the [download and install script](./template-only-bin/download-and-install-template.sh) in your project's root directory.
23+
24+
```bash
25+
curl https://raw.githubusercontent.com/navapbc/template-application-flask/main/template-only-bin/download-and-install-template.sh | bash -s
26+
```
27+
28+
This script will:
29+
30+
1. Clone the template repository
31+
2. Copy the template files into your project directory
32+
3. Remove any files specific to the template repository.
33+
2. Optional, if using the Platform infra template: [Follow the steps in the `template-infra` README](https://github.com/navapbc/template-infra#installation) to set up the various pieces of your infrastructure.
34+
35+
## Getting started
3636

3737
Now you're ready to [get started](/docs/app/getting-started.md).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
echo "Fetch latest version of template-application-flask"
5+
git clone --single-branch --branch main --depth 1 git@github.com:navapbc/template-application-flask.git
6+
7+
echo "Install template"
8+
./template-application-flask/template-only-bin/install-template.sh
9+
10+
echo "Clean up template-application-flask folder"
11+
rm -fr template-application-flask
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# This script installs template-application-flask to your project. Run
4+
# This script from your project's root directory.
5+
set -euo pipefail
6+
7+
CUR_DIR=$(pwd)
8+
SCRIPT_DIR=$(dirname $0)
9+
TEMPLATE_DIR="$SCRIPT_DIR/.."
10+
11+
echo "Copy files from template-application-flask"
12+
cd $TEMPLATE_DIR
13+
cp -r \
14+
.github \
15+
.dockleconfig \
16+
.hadolint.yaml \
17+
app \
18+
docker-compose.yml \
19+
docs \
20+
$CUR_DIR
21+
cd -
22+
23+
echo "Remove files relevant only to template development"
24+
rm .github/workflows/template-only-*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
#
3+
# This script updates template-application-flask in your project. Run
4+
# This script from your project's root directory.
5+
set -euo pipefail
6+
7+
SCRIPT_DIR=$(dirname $0)
8+
9+
echo "Install template"
10+
$SCRIPT_DIR/install-template.sh

0 commit comments

Comments
 (0)