Add check in pipelines to build new artifact only when app changed (#14) #15
This file contains hidden or 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
| # purpose: run Continuous Delivery / Packaging (package) | |
| # variables: [] | |
| # secrets: [DOCKERHUB_USERNAME, DOCKERHUB_TOKEN] | |
| name: PKG | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: {} | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checks-out the repository | |
| uses: actions/checkout@v5 | |
| - name: Get changes files | |
| id: changed-files | |
| uses: tj-actions/changed-files@v47 | |
| with: | |
| files_yaml: | | |
| app: | |
| - src/** | |
| - test/** | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: check | |
| if: needs.check.outputs.app_any_changed == 'true' | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4 | |
| - name: Checkout workflow parts | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: devpro/github-workflow-parts | |
| ref: main | |
| path: workflow-parts | |
| - name: Build and push a new container image | |
| uses: ./workflow-parts/docker/build-push | |
| with: | |
| container_registry: docker.io | |
| container_username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| container_password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| docker_file: 'src/WebApi/Dockerfile' | |
| image_tag: 1.2.${{ github.run_id }} | |
| image_path: 'docker.io/devprofr' | |
| image_name: terraform-backend-mongodb | |
| create_latest: ${{ github.ref_name == 'main' }} |