-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a workflow to test and build the API-dummy image on github eli…
- Loading branch information
1 parent
c6d26fa
commit e073b2b
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: CI Pipeline | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Start test stack | ||
- name: Bring up test stack | ||
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up --wait | ||
- name: Debug bring up test stack | ||
if: failure() | ||
run: docker compose logs | ||
- name: Project Tests | ||
run: docker compose exec app bash /app/project_tests.sh | ||
- name: Smoke Tests | ||
run: docker compose exec app bash /app/smoke_tests.sh | ||
- name: Take down test stack | ||
if: always() | ||
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml down | ||
build-and-push: | ||
needs: [tests] | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/master' | ||
env: | ||
IMAGE_REPO: ghcr.io/elifesciences/api-dummy | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date --utc +%Y%m%d.%H%M)" >> $GITHUB_OUTPUT | ||
- name: Get sha with 8 chars long | ||
id: commit_sha | ||
run: echo "commit_sha=${GITHUB_SHA:0:8}" >> $GITHUB_OUTPUT | ||
- name: Build and push client image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
load: false | ||
platforms: linux/amd64,linux/arm64 | ||
target: prod | ||
tags: | | ||
${{ env.IMAGE_REPO }}:${{ github.sha }} | ||
${{ env.IMAGE_REPO }}:${{ env.BRANCH_NAME }}-${{ steps.commit_sha.outputs.commit_sha }}-${{ steps.date.outputs.date }} |