Skip to content

Commit 181219b

Browse files
committed
Add GH Actions
1 parent 43fec72 commit 181219b

8 files changed

Lines changed: 239 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build templates
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
artifact-key:
7+
description: "The key of the uploaded artifact"
8+
value: "dist-${{ github.run_id }}-${{ github.run_attempt }}"
9+
templates:
10+
description: "Template filenames and descriptions"
11+
value: ${{ jobs.build.outputs.templates }}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
templates: ${{ steps.build.outputs.templates }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: 3.9
25+
cache: pip
26+
- name: Install dependencies
27+
run: pip install -r requirements.txt
28+
- name: Build templates
29+
id: build
30+
run: |
31+
mkdir dist
32+
33+
python template.py -o dist/ecs-fargate-full.yml --launch-type=fargate
34+
echo "ecs-fargate-full.yml => Fargate" >> templates.txt
35+
36+
python template.py -o dist/ecs-fargate-no-network.yml --launch-type=fargate -N
37+
echo "ecs-fargate-no-network.yml => Fargate (no network)" >> templates.txt
38+
39+
python template.py -o dist/ecs-fargate-no-cluster.yml --launch-type=fargate -C -N
40+
echo "ecs-fargate-no-cluster.yml => Fargate (no cluster, no network)" >> templates.txt
41+
42+
python template.py -o dist/ecs-ec2-full.yml --launch-type=ec2
43+
echo "ecs-ec2-full.yml => EC2" >> templates.txt
44+
45+
python template.py -o dist/ecs-ec2-no-network.yml --launch-type=ec2 -N
46+
echo "ecs-ec2-no-network.yml => EC2 (no network)" >> templates.txt
47+
48+
python template.py -o dist/ecs-ec2-no-cluster.yml --launch-type=ec2 -C -N
49+
echo "ecs-ec2-no-cluster.yml => EC2 (no cluster, no network)" >> templates.txt
50+
51+
echo 'templates<<EOF' >> $GITHUB_OUTPUT
52+
cat templates.txt >> $GITHUB_OUTPUT
53+
echo 'EOF' >> $GITHUB_OUTPUT
54+
- name: Upload templates
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: dist-${{ github.run_id }}-${{ github.run_attempt }}
58+
path: dist
59+
retention-days: 1

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/build-templates.yml
11+
lint-templates:
12+
needs: build
13+
uses: ./.github/workflows/lint-templates.yml
14+
with:
15+
artifact-key: ${{ needs.build.outputs.artifact-key }}
16+
upload-templates:
17+
if: github.ref == 'refs/heads/master'
18+
permissions:
19+
contents: read
20+
id-token: write
21+
needs: [build, lint-templates]
22+
uses: ./.github/workflows/upload-templates.yml
23+
with:
24+
artifact-key: ${{ needs.build.outputs.artifact-key }}
25+
tag: latest
26+
secrets: inherit
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint templates
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
artifact-key:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build-and-lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
- name: Download templates
17+
uses: actions/download-artifact@v4
18+
with:
19+
name: ${{ inputs.artifact-key }}
20+
path: dist
21+
- name: Setup Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: 3.9
25+
cache: pip
26+
cache-dependency-path: requirements-dev.txt
27+
- name: Install dev dependencies
28+
run: pip install -r requirements-dev.txt
29+
- name: Lint templates
30+
run: cfn-lint dist/*.yml

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
jobs:
9+
build-and-lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Setup Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: 3.9
18+
cache: pip
19+
cache-dependency-path: requirements-dev.txt
20+
- name: Install dev dependencies
21+
run: pip install -r requirements-dev.txt
22+
- name: Lint with flake8
23+
run: flake8 ./template.py

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/build-templates.yml
11+
lint-templates:
12+
needs: build
13+
uses: ./.github/workflows/lint-templates.yml
14+
with:
15+
artifact-key: ${{ needs.build.outputs.artifact-key }}
16+
upload-templates:
17+
permissions:
18+
contents: read
19+
id-token: write
20+
needs: [build, lint-templates]
21+
uses: ./.github/workflows/upload-templates.yml
22+
with:
23+
artifact-key: ${{ needs.build.outputs.artifact-key }}
24+
tag: ${{ github.ref_name }}
25+
secrets: inherit
26+
release:
27+
needs: [build, lint-templates, upload-templates]
28+
runs-on: ubuntu-latest
29+
permissions:
30+
contents: write
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Prepare notes
35+
id: prepare-notes
36+
env:
37+
TEMPLATES: ${{ needs.build.outputs.templates }}
38+
run: |
39+
# Extract changelog entries between this and previous version headers
40+
escaped_version=$(echo ${GITHUB_REF_NAME#v} | sed -e 's/[]\/$*.^[]/\\&/g')
41+
awk "BEGIN{inrelease=0} /## \[${escaped_version}\]/{inrelease=1;next} /## \[[0-9]+\.[0-9]+\.[0-9]+.*\]/{inrelease=0;exit} {if (inrelease) print}" CHANGELOG.md \
42+
> RELEASE_NOTES.txt
43+
44+
echo "" >> RELEASE_NOTES.txt
45+
echo "| Template | |" >> RELEASE_NOTES.txt
46+
echo "| --- | --- |" >> RELEASE_NOTES.txt
47+
echo "$TEMPLATES" | awk 'BEGIN{FS=" => "}{print "| " $2 " | [![](assets/launch-stack.svg)](https://console.aws.amazon.com/cloudformation/home#/stacks/new?stackName=imgproxy&templateURL=https://imgproxy-cf.s3.amazonaws.com/${{ github.ref_name }}/" $1 ") |"}' >> RELEASE_NOTES.txt
48+
49+
# Write prerelease="true" env if tag name has any suffix after vMAJOR.MINOR.PATCH
50+
if [[ ${GITHUB_REF_NAME} =~ ^v[0-9]+\.[0-9]+\.[0-9]+.+ ]]; then
51+
echo 'prerelease="true"' >> $GITHUB_OUTPUT
52+
else
53+
echo 'prerelease="false"' >> $GITHUB_OUTPUT
54+
fi
55+
- name: Release
56+
uses: softprops/action-gh-release@v1
57+
with:
58+
body_path: RELEASE_NOTES.txt
59+
prerelease: ${{ fromJSON(steps.prepare-notes.outputs.prerelease) }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Upload Templates to S3
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
artifact-key:
7+
required: true
8+
type: string
9+
tag:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
upload:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
id-token: write
19+
steps:
20+
- name: Configure AWS Credentials
21+
uses: aws-actions/configure-aws-credentials@v4
22+
with:
23+
audience: sts.amazonaws.com
24+
aws-region: us-east-1
25+
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
26+
- name: Download templates
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: ${{ inputs.artifact-key }}
30+
path: dist
31+
- name: Upload templates
32+
run: aws s3 cp dist s3://imgproxy-cf/${{ inputs.tag }} --recursive

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<a href="https://discord.gg/5GgpXgtC9u">Discord</a>
1919
</h4>
2020

21+
<p align="center">
22+
<a href="https://github.com/imgproxy/imgproxy-cloudformation/actions"><img alt="GH Build" src="https://img.shields.io/github/actions/workflow/status/imgproxy/imgproxy-cloudformation/build.yml?branch=master&label=Build&style=for-the-badge" /></a>
23+
<a href="https://github.com/imgproxy/imgproxy-cloudformation/actions"><img alt="GH Lint" src="https://img.shields.io/github/actions/workflow/status/imgproxy/imgproxy-cloudformation/lint.yml?branch=master&label=Lint&style=for-the-badge" /></a>
24+
</p>
25+
2126
---
2227

2328
[imgproxy](https://imgproxy.net) is a fast and secure standalone server for resizing and converting remote images. The main principles of imgproxy are simplicity, speed, and security.
@@ -28,6 +33,9 @@ This repository contains a [troposphere](https://github.com/cloudtools/troposphe
2833

2934
We prepared a few pre-built templates that you can use right away. Just click on a link, set the required options, and you're ready to process your images.
3035

36+
> [!NOTE]
37+
> The links in the README point to the templates built from the `master` branch. If you want to use a specific version, you can find the links in the [releases](https://github.com/imgproxy/imgproxy-cloudformation/releases) section.
38+
3139
### Full intallation
3240

3341
These templates create all the required resources, plug-n-play:

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
flake8>=6.1.0
2+
cfn-lint>=0.83.6

0 commit comments

Comments
 (0)