chore(deps-dev): Bump svelte in /frontend/user-dashboard #366
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: Build and deploy services | |
on: | |
push: | |
paths: | |
- ".github/workflows/**" | |
- "deployments/**" | |
- "pkg/**" | |
- "internal/**" | |
- "cmd/**" | |
- "frontend/user-dashboard/**" | |
- "frontend/galactic-sovereign-frontend/**" | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-paths | |
- "!build/user-service/version.txt" | |
- "!build/user-dashboard/version.txt" | |
- "!build/galactic-sovereign-frontend/version.txt" | |
- "!build/galactic-sovereign-service/version.txt" | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs#example-only-cancel-in-progress-jobs-on-specific-branches | |
# https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
# https://github.com/dorny/paths-filter | |
detect-code-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
ci: ${{ steps.filter.outputs.ci }} | |
deployment: ${{ steps.filter.outputs.deployment }} | |
user-service: ${{ steps.filter.outputs.user-service }} | |
galactic-sovereign-service: ${{ steps.filter.outputs.galactic-sovereign-service }} | |
user-dashboard: ${{ steps.filter.outputs.user-dashboard }} | |
galactic-sovereign-frontend: ${{ steps.filter.outputs.galactic-sovereign-frontend }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
base: ${{ github.ref_name }} | |
filters: | | |
ci: | |
- '.github/workflows/build-and-deploy.yml' | |
deployment: | |
- 'deployments/**' | |
user-service: | |
- 'go.mod' | |
- 'pkg/**' | |
- 'internal/**' | |
- 'cmd/users/**' | |
- '.github/workflows/user-service**' | |
- '.github/workflows/services**' | |
galactic-sovereign-service: | |
- 'go.mod' | |
- 'pkg/**' | |
- 'internal/**' | |
- 'cmd/galactic-sovereign/**' | |
- '.github/workflows/galactic-sovereign-service**' | |
- '.github/workflows/services**' | |
user-dashboard: | |
- 'frontend/user-dashboard/**' | |
- '.github/workflows/user-dashboard**' | |
- '.github/workflows/services**' | |
galactic-sovereign-frontend: | |
- 'frontend/galactic-sovereign-frontend/**' | |
- '.github/workflows/galactic-sovereign-frontend-build-and-push.yml' | |
- '.github/workflows/services**' | |
analyze-code-changes: | |
runs-on: ubuntu-latest | |
needs: [detect-code-changes] | |
outputs: | |
user-service: ${{ steps.user-service.outputs.rebuild }} | |
galactic-sovereign-service: ${{ steps.galactic-sovereign-service.outputs.rebuild }} | |
user-dashboard: ${{ steps.user-dashboard.outputs.rebuild }} | |
galactic-sovereign-frontend: ${{ steps.galactic-sovereign-frontend.outputs.rebuild }} | |
steps: | |
- name: Determine user-service rebuild status | |
id: user-service | |
run: | | |
echo 'rebuild=${{ needs.detect-code-changes.outputs.user-service == 'true' }}' >> $GITHUB_OUTPUT | |
- name: Determine galactic-sovereign-service rebuild status | |
id: galactic-sovereign-service | |
run: | | |
echo 'rebuild=${{ needs.detect-code-changes.outputs.galactic-sovereign-service == 'true' }}' >> $GITHUB_OUTPUT | |
- name: Determine user-dashboard rebuild status | |
id: user-dashboard | |
run: | | |
echo 'rebuild=${{ needs.detect-code-changes.outputs.user-dashboard == 'true' }}' >> $GITHUB_OUTPUT | |
- name: Determine galactic-sovereign-frontend rebuild status | |
id: galactic-sovereign-frontend | |
run: | | |
echo 'rebuild=${{ needs.detect-code-changes.outputs.galactic-sovereign-frontend == 'true' }}' >> $GITHUB_OUTPUT | |
analyze-persist-tags-status: | |
runs-on: ubuntu-latest | |
needs: [detect-code-changes, analyze-code-changes] | |
outputs: | |
persist: ${{ steps.persist-tags.outputs.persist }} | |
steps: | |
- name: Detect if service tags should be persisted | |
id: persist-tags | |
run: | | |
echo 'persist=${{ (github.ref == 'refs/heads/master') && (needs.analyze-code-changes.outputs.user-service == 'true' || needs.analyze-code-changes.outputs.galactic-sovereign-service == 'true' || needs.analyze-code-changes.outputs.user-dashboard == 'true' || needs.analyze-code-changes.outputs.galactic-sovereign-frontend == 'true') }}' >> $GITHUB_OUTPUT | |
analyze-deploy-status: | |
runs-on: ubuntu-latest | |
needs: [detect-code-changes, analyze-persist-tags-status] | |
outputs: | |
deploy-services: ${{ steps.deploy-services.outputs.deploy }} | |
steps: | |
- name: Detect if services should be deployed | |
id: deploy-services | |
run: | | |
echo 'deploy=${{ (github.ref == 'refs/heads/master') && (needs.analyze-persist-tags-status.outputs.persist == 'true' || needs.detect-code-changes.outputs.deployment == 'true' || needs.detect-code-changes.outputs.ci == 'true') }}' >> $GITHUB_OUTPUT | |
tests: | |
runs-on: ubuntu-latest | |
needs: [analyze-code-changes] | |
if: ${{ needs.analyze-code-changes.outputs.user-service == 'true' || needs.analyze-code-changes.outputs.galactic-sovereign-service == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23.2" | |
- name: Run tests with coverage | |
run: go test ./... -coverpkg=./... -race -covermode=atomic -coverprofile=coverage.out | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
file: ./coverage.out | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build-user-service: | |
needs: [tests] | |
uses: ./.github/workflows/user-service-build-and-push.yml | |
secrets: | |
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} | |
build-galactic-sovereign-service: | |
needs: [tests] | |
uses: ./.github/workflows/galactic-sovereign-service-build-and-push.yml | |
secrets: | |
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} | |
build-user-dashboard: | |
needs: [analyze-code-changes] | |
if: ${{ needs.analyze-code-changes.outputs.user-dashboard == 'true' }} | |
uses: ./.github/workflows/user-dashboard-build-and-push.yml | |
secrets: | |
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} | |
build-galactic-sovereign-frontend: | |
needs: [analyze-code-changes] | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-frontend == 'true' }} | |
uses: ./.github/workflows/galactic-sovereign-frontend-build-and-push.yml | |
secrets: | |
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} | |
backup-deployment-config: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds | |
needs: | |
[ | |
analyze-deploy-status, | |
build-user-service, | |
build-galactic-sovereign-service, | |
build-user-dashboard, | |
build-galactic-sovereign-frontend, | |
] | |
# https://github.com/actions/runner/issues/491 | |
# https://github.com/actions/runner/issues/2205#issuecomment-1400087739 | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.analyze-deploy-status.outputs.deploy-services == 'true' | |
steps: | |
- name: Back-up deployment config | |
uses: appleboy/ssh-action@v1.1.0 | |
with: | |
host: "${{ secrets.EC2_DEPLOY_HOST }}" | |
username: ubuntu | |
key: ${{ secrets.EC2_DEPLOY_SSH_KEY }} | |
script: | | |
rm -rf ~/deployments.bak | |
mv ~/deployments ~/deployments.bak | |
mkdir ~/deployments | |
sync-deployment-configuration: | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
backup-deployment-config, | |
analyze-code-changes, | |
analyze-deploy-status, | |
build-user-service, | |
build-galactic-sovereign-service, | |
build-user-dashboard, | |
build-galactic-sovereign-frontend, | |
] | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.analyze-deploy-status.outputs.deploy-services == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Substitute acme email | |
run: | | |
mv deployments/traefik-template.yml deployments/traefik.yml | |
sed -i 's/${EMAIL_TO_BE_REPLACED}/${{ secrets.ACME_EMAIL }}/g' deployments/traefik.yml | |
- name: Configure docker-compose deployment | |
# https://deploy-preview-13474--docsdocker.netlify.app/compose/env-file/#compose-2x | |
run: | | |
echo "ENV_USER_DATABASE_PASSWORD=${{ secrets.USER_SERVICE_DATABASE_MANAGER_PASSWORD }}" >> ./deployments/.env | |
echo "ENV_GALACTIC_SOVEREIGN_DATABASE_PASSWORD=${{ secrets.GALACTIC_SOVEREIGN_DATABASE_MANAGER_PASSWORD }}" >> ./deployments/.env | |
echo "USER_DASHBOARD_ORIGIN=${{ secrets.USER_DASHBOARD_ORIGIN }}" >> ./deployments/.env | |
echo "GALACTIC_SOVEREIGN_FRONTEND_ORIGIN=${{ secrets.GALACTIC_SOVEREIGN_FRONTEND_ORIGIN }}" >> ./deployments/.env | |
echo "DOMAIN_NAME=${{ secrets.DOMAIN_NAME }}" >> ./deployments/.env | |
echo "TRAEFIK_USER=${{ secrets.TRAEFIK_USER }}" >> ./deployments/.env | |
echo "TRAEFIK_HASHED_PASSWORD='"'${{ secrets.TRAEFIK_HASHED_PASSWORD }}'"'" >> ./deployments/.env | |
- name: Configure user-service tag from workflow output | |
if: ${{ needs.analyze-code-changes.outputs.user-service == 'true' }} | |
run: | | |
echo "USER_SERVICE_TAG=${{ needs.build-user-service.outputs.service-tag }}" >> ./deployments/.env | |
- name: Configure user-service tag from existing tag | |
if: ${{ needs.analyze-code-changes.outputs.user-service == 'false' }} | |
run: | | |
echo "USER_SERVICE_TAG=$(cat ./build/user-service/version.txt)" >> ./deployments/.env | |
- name: Configure galactic-sovereign-service tag from workflow output | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-service == 'true' }} | |
run: | | |
echo "GALACTIC_SOVEREIGN_SERVICE_TAG=${{ needs.build-galactic-sovereign-service.outputs.service-tag }}" >> ./deployments/.env | |
- name: Configure galactic-sovereign-service tag from existing tag | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-service == 'false' }} | |
run: | | |
echo "GALACTIC_SOVEREIGN_SERVICE_TAG=$(cat ./build/galactic-sovereign-service/version.txt)" >> ./deployments/.env | |
- name: Configure user-dashboard tag from workflow output | |
if: ${{ needs.analyze-code-changes.outputs.user-dashboard == 'true' }} | |
run: | | |
echo "USER_DASHBOARD_TAG=${{ needs.build-user-dashboard.outputs.service-tag }}" >> ./deployments/.env | |
- name: Configure user-dashboard tag from existing tag | |
if: ${{ needs.analyze-code-changes.outputs.user-dashboard == 'false' }} | |
run: | | |
echo "USER_DASHBOARD_TAG=$(cat ./build/user-dashboard/version.txt)" >> ./deployments/.env | |
- name: Configure galactic-sovereign-frontend tag from workflow output | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-frontend == 'true' }} | |
run: | | |
echo "GALACTIC_SOVEREIGN_FRONTEND_TAG=${{ needs.build-galactic-sovereign-frontend.outputs.service-tag }}" >> ./deployments/.env | |
- name: Configure galactic-sovereign-frontend tag from existing tag | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-frontend == 'false' }} | |
run: | | |
echo "GALACTIC_SOVEREIGN_FRONTEND_TAG=$(cat ./build/galactic-sovereign-frontend/version.txt)" >> ./deployments/.env | |
- name: Install SSH keys | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.EC2_DEPLOY_SSH_KEY }} | |
known_hosts: ${{ secrets.EC2_DEPLOY_SSH_KNOWN_HOSTS }} | |
- name: Sync deployment configuration | |
# https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/#3_Copy_a_Directory_from_Local_to_Remote_Server | |
run: | | |
rsync -avzh ./deployments ubuntu@${{ secrets.EC2_DEPLOY_HOST }}:/home/ubuntu/ | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [analyze-deploy-status, sync-deployment-configuration] | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.analyze-deploy-status.outputs.deploy-services == 'true' | |
steps: | |
- name: Deploy latest services version | |
uses: appleboy/ssh-action@v1.1.0 | |
with: | |
host: "${{ secrets.EC2_DEPLOY_HOST }}" | |
username: ubuntu | |
key: ${{ secrets.EC2_DEPLOY_SSH_KEY }} | |
script: | | |
docker compose -f ./deployments/compose.yaml up -d --remove-orphans | |
clean-deployment-config-backup: | |
runs-on: ubuntu-latest | |
needs: [analyze-deploy-status, deploy] | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.analyze-deploy-status.outputs.deploy-services == 'true' | |
steps: | |
- name: Clean back-up of deployment config | |
uses: appleboy/ssh-action@v1.1.0 | |
with: | |
host: "${{ secrets.EC2_DEPLOY_HOST }}" | |
username: ubuntu | |
key: ${{ secrets.EC2_DEPLOY_SSH_KEY }} | |
script: | | |
rm -rf ~/deployments.bak | |
persist-service-tags: | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
analyze-code-changes, | |
analyze-persist-tags-status, | |
build-user-service, | |
build-galactic-sovereign-service, | |
build-user-dashboard, | |
build-galactic-sovereign-frontend, | |
clean-deployment-config-backup, | |
] | |
# https://github.com/actions/runner/issues/491 | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
github.ref == 'refs/heads/master' && | |
needs.analyze-persist-tags-status.outputs.persist == 'true' | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Save user-service tag | |
if: ${{ needs.analyze-code-changes.outputs.user-service == 'true' }} | |
run: | | |
echo "${{ needs.build-user-service.outputs.service-tag }}" > ./build/user-service/version.txt | |
- name: Save galactic-sovereign-service tag | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-service == 'true' }} | |
run: | | |
echo "${{ needs.build-galactic-sovereign-service.outputs.service-tag }}" > ./build/galactic-sovereign-service/version.txt | |
- name: Save user-dashboard tag | |
if: ${{ needs.analyze-code-changes.outputs.user-dashboard == 'true' }} | |
run: | | |
echo "${{ needs.build-user-dashboard.outputs.service-tag }}" > ./build/user-dashboard/version.txt | |
- name: Save galactic-sovereign-frontend tag | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-frontend == 'true' }} | |
run: | | |
echo "${{ needs.build-galactic-sovereign-frontend.outputs.service-tag }}" > ./build/galactic-sovereign-frontend/version.txt | |
- name: Commit changes | |
run: | | |
git pull | |
git config --global user.name 'totocorpbot' | |
git config --global user.email 'totocorpbot@users.noreply.github.com' | |
git commit -am "infra: Bumped services versions to latest revision" | |
git push | |
finish: | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
analyze-code-changes, | |
analyze-deploy-status, | |
build-user-service, | |
build-galactic-sovereign-service, | |
build-user-dashboard, | |
build-galactic-sovereign-frontend, | |
persist-service-tags, | |
] | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: user-service tag | |
if: ${{ needs.analyze-code-changes.outputs.user-service == 'true' }} | |
run: | | |
echo "Tag is now $(cat ./build/user-service/version.txt)" | |
- name: galactic-sovereign-service tag | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-service == 'true' }} | |
run: | | |
echo "Tag is now $(cat ./build/galactic-sovereign-service/version.txt)" | |
- name: user-dashboard tag | |
if: ${{ needs.analyze-code-changes.outputs.user-dashboard == 'true' }} | |
run: | | |
echo "Tag is now $(cat ./build/user-dashboard/version.txt)" | |
- name: galactic-sovereign-frontend tag | |
if: ${{ needs.analyze-code-changes.outputs.galactic-sovereign-frontend == 'true' }} | |
run: | | |
echo "Tag is now $(cat ./build/galactic-sovereign-frontend/version.txt)" | |
- name: deployed | |
if: ${{ needs.analyze-deploy-status.outputs.deploy-services }} | |
run: | | |
echo "Services were deployed" |