-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b681cc1
commit d934199
Showing
3 changed files
with
86 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: TestAndDeploy | ||
|
||
on: push | ||
|
||
env: | ||
CI_PROJECT_NAME: sd-simpro-ng-int | ||
CI_DOCKER_REGISTRY_URL: registry.digitalocean.com | ||
CI_CD_REPOSITORY_NAME: RonasIT/sd-simpro-ng-int-dkc | ||
CI_CD_REPOSITORY_EVENT_TYPE: trigger-deployment | ||
|
||
jobs: | ||
|
||
Tests: | ||
runs-on: ubuntu-latest | ||
env: | ||
COMPOSE_FILE: .github/docker-compose.yml | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Prepare .env | ||
run: | | ||
cp .env.testing .env | ||
- name: Docker-Compose Up | ||
run: | | ||
docker-compose up -d | ||
- name: Set Permissions | ||
run: | | ||
docker-compose exec -T nginx chown -R www-data:www-data /app | ||
docker-compose exec -T nginx chmod -R 755 /app | ||
- name: Prepare Containers | ||
run: | | ||
docker-compose exec -T nginx composer install | ||
docker-compose exec -T nginx php artisan jwt:secret --env=testing | ||
docker-compose exec -T nginx php artisan key:generate --env=testing | ||
- name: Run Tests | ||
run: | | ||
docker-compose exec -T nginx php vendor/bin/phpunit --stop-on-failure ./tests/ | ||
- name: Logs | ||
run: | | ||
docker-compose exec -T nginx cat storage/logs/*.log || true | ||
Deploy: | ||
runs-on: ubuntu-latest | ||
needs: Tests | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set Environment | ||
run: | | ||
if ${{ github.ref == 'refs/heads/main' }}; then | ||
echo "CI_PROJECT_ENV_NAME=prod" >> $GITHUB_ENV | ||
CI_PROJECT_ENV_NAME=prod | ||
else | ||
echo "CI_PROJECT_ENV_NAME=dev" >> $GITHUB_ENV | ||
CI_PROJECT_ENV_NAME=dev | ||
fi | ||
echo "CI_DOCKER_IMAGE=$CI_DOCKER_REGISTRY_URL/$CI_PROJECT_NAME/$CI_PROJECT_NAME-$CI_PROJECT_ENV_NAME:${{ github.run_id }}" >> $GITHUB_ENV | ||
- name: Create .env file | ||
run: | | ||
cp .env.$CI_PROJECT_ENV_NAME .env | ||
- name: Set Up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set Up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login To DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: registry.digitalocean.com | ||
username: ${{ secrets.DIGITAL_OCEAN_ACCESS_TOKEN }} | ||
password: ${{ secrets.DIGITAL_OCEAN_ACCESS_TOKEN }} | ||
- name: Build And Push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ env.CI_DOCKER_IMAGE }} | ||
- name: Trigger Deployment | ||
uses: peter-evans/repository-dispatch@v2 | ||
with: | ||
token: ${{ secrets.CI_CD_REPOSITORY_ACCESS_TOKEN }} | ||
repository: ${{ env.CI_CD_REPOSITORY_NAME }} | ||
event-type: ${{ env.CI_CD_REPOSITORY_EVENT_TYPE }} | ||
client-payload: '{"image": "${{ env.CI_DOCKER_IMAGE }}", "env_name": "${{ env.CI_PROJECT_ENV_NAME }}", "project_name": "${{ env.CI_PROJECT_NAME }}"}' |
This file was deleted.
Oops, something went wrong.
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