Merge pull request #42 from R-OV-NL/development #52
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: Build, Test, and Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.SHARED_PAT }} | |
submodules: recursive | |
# Set up Docker | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Build the test stage of the Dockerfile | |
- name: Rebuild Compose Images | |
run: docker compose -f docker-compose.test.yml build --no-cache | |
- name: Test image with Docker Compose | |
run: docker compose -f docker-compose.test.yml up --force-recreate --abort-on-container-exit --exit-code-from app | |
release: | |
runs-on: ubuntu-latest | |
needs: build-and-test | |
if: github.ref == 'refs/heads/main' | |
steps: | |
# Checkout the repository | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.SHARED_PAT }} | |
submodules: recursive | |
# Log in to DockerHub | |
- name: Log in to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Build the release stage of the Dockerfile | |
- name: Build and Push Docker Image | |
run: | | |
docker build --target release -t r_ov:gtfsrt . | |
docker tag r_ov:gtfsrt arilith/r_ov:gtfsrt | |
docker push arilith/r_ov:gtfsrt | |
# Deploy the new Docker image by running the workflow in the Deploy repository | |
- name: Deploy new Docker image | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
workflow: Deploy Docker Images of R-OV | |
repo: R-OV-NL/Deploy | |
token: ${{ secrets.SHARED_PAT }} | |
ref: main |