Skip to content

Commit

Permalink
Does this workflow work?
Browse files Browse the repository at this point in the history
  • Loading branch information
Sara Veldhoen committed Apr 15, 2024
1 parent 56f62b6 commit 429b36f
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 5 deletions.
5 changes: 0 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,3 @@ updates:
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "pip"
insecure-external-code-execution: "deny"
directory: "/"
schedule:
interval: "daily"
37 changes: 37 additions & 0 deletions .github/workflows/_build-push-cached-ecr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build image (with docker cache) and push to ECR

on:
workflow_call:

jobs:
docker:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::917951871879:role/GitHubActionsBgOrg
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Compile metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.login-ecr.outputs.registry }}/dane-video-segmentation-worker
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Build and push
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
41 changes: 41 additions & 0 deletions .github/workflows/_build-push-cached-ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy dane-example-worker to ghcr

on:
workflow_call:

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=edge,enable={{is_default_branch}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
22 changes: 22 additions & 0 deletions .github/workflows/_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy

on:
workflow_call:
inputs:
target:
type: string
required: true

jobs:
deploy-ecr:
if: ${{ inputs.target == 'ecr' }}
uses: ./.github/workflows/_build-push-cached-ecr.yml
permissions:
id-token: write
contents: read
deploy-ghrc:
if: ${{ inputs.target == 'ghcr' }}
uses: ./.github/workflows/_build-push-cached-ghcr.yml
permissions:
contents: read
packages: write
43 changes: 43 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test

on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: "Checkout Repository"
uses: "actions/checkout@v4"

- name: "Install Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.10"

- name: "Install poetry"
run: "pip install --user poetry"

- name: "Install dev environment"
run: poetry install --no-interaction --no-ansi

- name: install libgl1
run: sudo apt-get install -y libgl1

- name: install ffmpeg
run: sudo apt-get update && sudo apt-get install -y ffmpeg --fix-missing

- name: "pytest"
run: |
cp config/config.yml config.yml
poetry run pytest
- name: "flake8"
run: "poetry run flake8"

- name: "black"
run: "poetry run black --check ."

- name: "mypy"
run: "poetry run mypy ."
21 changes: 21 additions & 0 deletions .github/workflows/main-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: main branch - test; deploy (ecr, tst, acc, aws)

on:
push:
branches:
- "main"
paths-ignore:
- README.md
- LICENSE
- docker-compose.yml

jobs:
test:
uses: ./.github/workflows/_test.yml

deploy:
uses: ./.github/workflows/_deploy.yml
secrets: inherit
needs: [test]
with:
target: ghcr
18 changes: 18 additions & 0 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Manual deploy

on:
workflow_dispatch:
inputs:
target:
type: choice
required: true
default: ghcr
options:
- ghcr

jobs:
deploy:
uses: ./.github/workflows/_deploy.yml
secrets: inherit
with:
target: ${{ inputs.target }}
14 changes: 14 additions & 0 deletions .github/workflows/not-main-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: All branches but main - test only

on:
push:
branches-ignore:
- "main"
paths-ignore:
- README.md
- LICENSE
- docker-compose.yml

jobs:
test:
uses: "./.github/workflows/_test.yml"

0 comments on commit 429b36f

Please sign in to comment.