Skip to content

Commit

Permalink
(smol) refactor actions (#1141)
Browse files Browse the repository at this point in the history
* add build-containers workflow

* move around action files

* another try

* crossed fingers
  • Loading branch information
rococodogs authored Sep 9, 2024
1 parent 581f6cf commit 53774d6
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 279 deletions.
85 changes: 0 additions & 85 deletions .github/actions/build-containers/action.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/build-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build containers
on:
workflow_call:
secrets:
username:
required: true
description: "Username value for container repository"
password:
required: true
description: "Password/token value for container repository"
registry:
required: false
description: "URL for container repository (default: DockerHub)"
inputs:
tag:
type: string
required: true
description: "Version identifier for release"
services:
type: string
required: true
description: "Stringified JSON array of which service containers to build"
default: '["rails","sidekiq","fcrepo","solr","fits_servlet"]'
environments:
type: string
required: true
description: Stringified JSON array of GitHub environments to use for variables
default: '["stage","production"]'

jobs:
build_containers:
name: Build containers
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
strategy:
matrix:
environment: ${{ fromJson(inputs.environments) }}
service:
-
name: rails
image: lafayette/rails
context: .
target: spot-web-production
-
name: sidekiq
image: lafayette/sidekiq
context: .
target: spot-worker-production
-
name: solr
image: lafayette/solr
context: ./docker/solr
-
name: fcrepo
image: lafayette/fc
context: ./docker/fcrepo
-
name: fits_servlet
image: lafayette/fits_servlet
context: ./docker/fits_servlet
steps:
- uses: actions/checkout@v4
-
name: Log into Docker
uses: docker/login-action@v2
with:
registry: ${{ secrets.registry || 'docker.io' }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build and push ${{ matrix.service.image }} container
uses: ./.github/actions/build-container
if: ${{ contains(fromJson(inputs.services), matrix.service.name) }}
with:
registry: ${{ secrets.registry || 'docker.io' }}
tag: ${{ inputs.tag }}
image_name: ${{ matrix.service.image }}
context: ${{ matrix.service.context }}
target: ${{ matrix.service.target }}
32 changes: 32 additions & 0 deletions .github/workflows/build-dev-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build development containers
on:
push:
branches:
- develop
- refactor-actions # remove this before merging!

release:
types:
- prereleased

permissions:
checks: write

jobs:
lint_and_test:
name: Lint + Test
uses: ./.github/workflows/lint-and-test.yml

build_and_push_development_containers:
name: Build and push dev containers
uses: ./.github/workflows/build-containers.yml
needs: [lint_and_test]
secrets:
registry: ${{ secrets.CONTAINER_REGISTRY }}
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
with:
tag: ${{ github.event.release.tag_name || github.ref_name }}
environments: '["stage"]'
services: '["rails","sidekiq","fcrepo","solr","fits_servlet"]'

Loading

0 comments on commit 53774d6

Please sign in to comment.