Skip to content

Commit

Permalink
Fix pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
filipopo committed Dec 14, 2024
1 parent c8207fc commit 720e94f
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 24 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3

- name: Set up CDK for Terraform
run: npm install -g cdktf-cli
run: |
pip install --user pipenv
npm install -g cdktf-cli
- name: cdktf synth
run: cdktf synth
run: |
pipenv install
cdktf synth
working-directory: cdktf

- name: Set up Terraform
uses: hashicorp/setup-terraform@v3

- name: Make Terraform plan
run: |
terraform init
Expand Down Expand Up @@ -71,6 +75,9 @@ jobs:

- name: Deploy
run: |
terraform -chdir=cdktf.out/stacks/urlshortener-stack apply tfplan
sh swa.sh ${{ github.event.inputs.image_tag }}
working-directory: cdktf
terraform init
terraform apply tfplan
working-directory: cdktf.out/stacks/urlshortener-stack

- name: Upload static files
run: sh swa.sh ${{ github.event.inputs.image_tag }}
20 changes: 4 additions & 16 deletions .github/workflows/ci.yaml → .github/workflows/ci - app.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: CI
name: CI - app

on:
push:
branches:
- main
paths:
- 'app/**'

jobs:
test:
Expand All @@ -16,12 +18,6 @@ jobs:
with:
python-version: 3.12

- name: Install test dependencies
run: pip install flake8

- name: Lint code
run: flake8 --extend-ignore=E501

- name: Install app dependencies
run: pip install -r app/requirements.txt

Expand All @@ -44,8 +40,7 @@ jobs:

- name: Build and push Docker images
run: |
ACC=filipmania
IMAGE=${ACC}/urlshortener
IMAGE=filipmania/urlshortener
docker build -t ${IMAGE}:${GITHUB_RUN_ID} -t ${IMAGE}:latest .
docker push ${IMAGE}:${GITHUB_RUN_ID}
Expand All @@ -59,12 +54,5 @@ jobs:
docker push ${IMAGE}:${GITHUB_RUN_ID}-nginx
docker push ${IMAGE}:nginx
docker pull nginx:latest
VER=$(docker run --rm nginx:latest nginx -v 2>&1 1>/dev/null | cut -d/ -f2)
docker build -t ${ACC}/nginx:${VER} -t ${ACC}/nginx:latest -f compose/Dockerfile compose
docker push ${ACC}/nginx:${VER}
docker push ${ACC}/nginx:latest
- name: Save the IMAGE_TAG
run: echo "IMAGE_TAG=${GITHUB_RUN_ID}"
26 changes: 26 additions & 0 deletions .github/workflows/ci - code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI - code

on:
push:
branches:
- main
paths:
- 'app/**'
- 'cdktf/**'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install test dependencies
run: pip install flake8

- name: Lint code
run: flake8 --extend-ignore=E501
38 changes: 38 additions & 0 deletions .github/workflows/ci - nginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI - nginx

on:
push:
branches:
- main
paths:
- 'compose/**'
schedule:
- cron: '0 0 * * Mon'

jobs:
build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker images
run: |
IMAGE=filipmania/nginx
docker pull nginx:latest
VER=$(docker run --rm nginx:latest nginx -v 2>&1 1>/dev/null | cut -d/ -f2)
docker build -t ${IMAGE}:${VER} -t ${IMAGE}:latest -f compose/Dockerfile compose
docker push ${IMAGE}:${VER}
docker push ${IMAGE}:latest
- name: Save the IMAGE_TAG
run: echo "IMAGE_TAG=${GITHUB_RUN_ID}"

0 comments on commit 720e94f

Please sign in to comment.