Added image publishing to the ghcr for every release, chnaged the def… #315
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
| name: MonarcAppFO releases | |
| on: | |
| push: | |
| branches: [ 'master' ] | |
| tags: [ 'v*.*', 'v*.*.*', 'v*.*.*-*' ] | |
| pull_request: | |
| branches: [ 'master' ] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [ "16.x" ] | |
| php-version: [ "8.1" ] | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: install deps | |
| run: sudo apt-get update && sudo apt install -y gettext | |
| # PHP | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php-version }} | |
| tools: composer:v2.3 | |
| extensions: bcmath | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate | |
| - name: Install PHP dependencies | |
| run: composer install --prefer-dist --no-progress --no-suggest --no-dev | |
| - name: Symlink Monarc modules | |
| run: | | |
| mkdir -p module/Monarc | |
| ln -s ../../vendor/monarc/core module/Monarc/Core | |
| ln -s ../../vendor/monarc/frontoffice module/Monarc/FrontOffice | |
| # javascript | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - uses: oprypin/find-latest-tag@v1 | |
| with: | |
| repository: monarc-project/ng-anr | |
| releases-only: true | |
| id: ng_anr_lasttag | |
| - run: echo "ng-anr is at version ${{ steps.ng_anr_lasttag.outputs.tag }}" | |
| - name: Install ng-anr | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: monarc-project/ng-anr | |
| ref: ${{ steps.ng_anr_lasttag.outputs.tag }} | |
| path: './node_modules/ng_anr' | |
| - uses: oprypin/find-latest-tag@v1 | |
| with: | |
| repository: monarc-project/ng-client | |
| releases-only: true | |
| id: ng_client_lasttag | |
| - run: echo "ng-client is at version ${{ steps.ng_client_lasttag.outputs.tag }}" | |
| - name: Install ng-client | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: monarc-project/ng-client | |
| ref: ${{ steps.ng_client_lasttag.outputs.tag }} | |
| path: './node_modules/ng_client' | |
| - name: Install ng-client dependencies | |
| run: | | |
| cd node_modules/ng_client | |
| npm ci | |
| # final "cleanup" | |
| - name: post job | |
| run: | | |
| bash -ex ./scripts/link_modules_resources.sh | |
| bash -ex ./scripts/compile_translations.sh | |
| # prepare release | |
| - name: Get repository name | |
| id: repository | |
| run: echo "::set-output name=pathref::$(echo '${{ github.repository }}' | cut -d'/' -f2)-$(echo '${{ github.ref_name }}' | sed 's/[^[:alnum:]\.-]/_/g')" | |
| - name: create artifact archive | |
| run: | | |
| tar --exclude .git --exclude .github -zcf '../${{ steps.repository.outputs.pathref }}.tar.gz' . | |
| - name: release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| ../${{ steps.repository.outputs.pathref }}.tar.gz | |
| fail_on_unmatched_files: true | |
| if: startsWith(github.ref, 'refs/tags/') | |
| - name: Set image names | |
| id: image_names | |
| if: startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| owner=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]') | |
| repo=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]') | |
| echo "app=ghcr.io/${owner}/${repo}" >> "$GITHUB_OUTPUT" | |
| echo "stats=ghcr.io/${owner}/${repo}-stats" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata (app) | |
| id: meta_app | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ steps.image_names.outputs.app }} | |
| tags: | | |
| type=raw,value=${{ github.ref_name }} | |
| type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} | |
| labels: | | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Build and push app image | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta_app.outputs.tags }} | |
| labels: ${{ steps.meta_app.outputs.labels }} | |
| - name: Docker metadata (stats) | |
| id: meta_stats | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ steps.image_names.outputs.stats }} | |
| tags: | | |
| type=raw,value=${{ github.ref_name }} | |
| type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }} | |
| labels: | | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Build and push stats image | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile.stats | |
| push: true | |
| tags: ${{ steps.meta_stats.outputs.tags }} | |
| labels: ${{ steps.meta_stats.outputs.labels }} |