2024-update #131
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: CI Build App | |
on: | |
push: | |
branches: [master] | |
paths: | |
- 'src/**' | |
- '.github/workflows/**' | |
pull_request: | |
env: | |
IMAGE_REG: ghcr.io | |
IMAGE_REPO: benc-uk/nodejs-demoapp | |
permissions: | |
packages: write | |
statuses: write | |
checks: write | |
jobs: | |
test: | |
name: 'Tests & Linting' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: 'Run linting' | |
run: make lint | |
- name: 'Run service' | |
run: make run & | |
- name: 'Run tests' | |
run: | | |
sleep 5 | |
make test-report | |
- name: 'Test reporting' | |
uses: phoenix-actions/test-reporting@v8 | |
id: test-report | |
if: success() || failure() | |
with: | |
name: Integration Test Report | |
path: test-results.xml | |
reporter: java-junit | |
fail-on-error: false | |
build: | |
name: 'Build & push image' | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
# Nicer than using github runid, I think, will be picked up automatically by make | |
- name: 'Create datestamp image tag' | |
run: echo "IMAGE_TAG=$(date +%d-%m-%Y.%H%M)" >> $GITHUB_ENV | |
- name: 'Docker build image' | |
run: make image | |
# Only when pushing to default branch (e.g. master or main), then push image to registry | |
- name: 'Push to container registry' | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login $IMAGE_REG -u $GITHUB_ACTOR --password-stdin | |
make push | |
# - name: 'Trigger AKS release pipeline' | |
# if: github.ref == 'refs/heads/master' | |
# uses: benc-uk/workflow-dispatch@v1 | |
# with: | |
# workflow: 'CD Release - AKS' | |
# token: ${{ secrets.GH_PAT }} | |
# inputs: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }' |