2024-update #127
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 | |
jobs: | |
test: | |
name: 'Tests & Linting' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v2 | |
- name: 'Run linting' | |
run: make lint | |
- name: 'Run service' | |
run: make run & | |
- name: 'Run tests' | |
run: | | |
sleep 10 | |
make test-report | |
- name: 'Test reporting' | |
uses: phoenix-actions/test-reporting@v8 | |
id: test-report | |
if: success() || failure() | |
with: | |
name: Unit Test Report | |
path: src/test-results.xml | |
reporter: java-junit | |
fail-on-error: false | |
build: | |
name: 'Build & push image' | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v2 | |
# 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' | |
if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
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 }}" }' |