Merge pull request #10 from alchemy-fr/PS-645-fix-upgrade #86
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: Build images, test, and then push | |
| on: push | |
| env: | |
| DOCKER_TAG: ${{ github.sha }} | |
| jobs: | |
| build_publish: | |
| name: 'Build' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: build | |
| run: | | |
| docker compose build | |
| - name: Test API | |
| run: | | |
| docker compose run --rm -e APP_ENV=dev api /bin/ash -c 'composer install && composer test' | |
| - name: Test HELM | |
| run: | | |
| curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | |
| chmod 700 get_helm.sh | |
| ./get_helm.sh | |
| helm template infra/helm/zippy -f bin/dev/myvalues.yaml | |
| helm lint infra/helm/zippy | |
| - name: Login to Docker Hub | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| if: env.DOCKERHUB_USERNAME != null && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Push images | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| if: env.DOCKERHUB_USERNAME != null && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) | |
| run: | | |
| docker image ls | grep ${{ env.DOCKER_TAG }} | awk '{ print $1 }' | xargs -I {} echo docker tag {}:${{ env.DOCKER_TAG }} {}:${{ github.ref_name }} | bash | |
| REGISTRY_NAMESPACE=alchemyfr/ps- DOCKER_TAG=${{ github.ref_name }} docker compose push | |
| - name: Push latest | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| if: env.DOCKERHUB_USERNAME != null && startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| LATEST_TAG=$(curl \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ github.token }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/${{ github.repository }}/releases/latest | jq --raw-output '.tag_name') | |
| if [ "${LATEST_TAG}" == "${{ github.ref_name }}" ]; then | |
| docker image ls | grep ${{ env.DOCKER_TAG }} | awk '{ print $1 }' | xargs -I {} echo docker tag {}:${{ env.DOCKER_TAG }} {}:latest | bash | |
| REGISTRY_NAMESPACE=alchemyfr/ps- DOCKER_TAG=latest docker compose push | |
| fi | |
| - name: Publish Helm charts | |
| if: github.ref == 'refs/heads/main' | |
| uses: stefanprodan/helm-gh-pages@master | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| charts_dir: ./infra/helm | |
| linting: off |