Improved docker compose compatibility with github actions #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run tests, build and push container images | |
on: | |
release: | |
types: | |
- "published" | |
push: | |
branches: | |
- "main" | |
env: | |
REGISTRY: ghcr.io | |
REGISTRY_NAMESPACE: ${{ github.repository_owner }} | |
CAPTAIN_IMAGE_NAME: captain | |
MATE_IMAGE_NAME: mate | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
test: | |
name: "Run tests" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v4 | |
- name: Set up improved Docker Buildx support | |
uses: docker/setup-buildx-action@v3 | |
- name: Run tests for captain | |
run: npm run docker:captain-test | |
- name: Run tests for mate | |
run: npm run docker:mate-test | |
- name: Obtain tag information for captain | |
id: meta-captain | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/${{ env.CAPTAIN_IMAGE_NAME }} | |
tags: | | |
type=semver,pattern={{raw}} | |
type=sha | |
- name: Obtain tag information for mate | |
id: meta-mate | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.REGISTRY }}/${{ env.REGISTRY_NAMESPACE }}/${{ env.MATE_IMAGE_NAME }} | |
tags: | | |
type=semver,pattern={{raw}} | |
type=sha | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Build and push captain" | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta-captain.outputs.tags }} | |
annotations: ${{ steps.meta-captain.outputs.annotations }} | |
context: './captain' | |
target: 'production-stage' | |
- name: "Build and push mate" | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta-mate.outputs.tags }} | |
annotations: ${{ steps.meta-mate.outputs.annotations }} | |
context: './mate' | |
target: 'production-stage' |