mirror of
https://github.com/2martens/cloud-configuration.git
synced 2026-10-17 16:46:51 +02:00
ci: Make further steps conditional on the environment being changed
This commit is contained in:
@@ -29,20 +29,23 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Exit if this environment wasn't changed
|
- name: Exit if this environment wasn't changed
|
||||||
|
id: check
|
||||||
run: |
|
run: |
|
||||||
echo "Changed envs: '${{ needs.fact-finding.outputs.changed_envs }}'"
|
echo "Changed envs: '${{ needs.fact-finding.outputs.changed_envs }}'"
|
||||||
if [[ ! " ${{ needs.fact-finding.outputs.changed_envs }} " =~ " ${{ matrix.env }} " ]]; then
|
if [[ ! " ${{ needs.fact-finding.outputs.changed_envs }} " =~ " ${{ matrix.env }} " ]]; then
|
||||||
echo "Environment '${{ matrix.env }}' was not modified. Skipping."
|
echo "should_deploy=true" >> $GITHUB_OUTPUT
|
||||||
exit 0
|
else
|
||||||
|
echo "should_deploy=false" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
shell: bash
|
||||||
- name: Build & push Nginx image to GHCR
|
- name: Build & push Nginx image to GHCR
|
||||||
if: steps.detect.outputs.changed_envs != ''
|
if: steps.check.outputs.should_deploy == 'true'
|
||||||
run: |
|
run: |
|
||||||
docker build -t ghcr.io/2martens/docker-nginx:${{ matrix.env }} docker/${{ matrix.env }}/nginx
|
docker build -t ghcr.io/2martens/docker-nginx:${{ matrix.env }} docker/${{ matrix.env }}/nginx
|
||||||
echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u 2martens --password-stdin
|
echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u 2martens --password-stdin
|
||||||
docker push ghcr.io/2martens/docker-nginx:${{ matrix.env }}
|
docker push ghcr.io/2martens/docker-nginx:${{ matrix.env }}
|
||||||
- name: Copy files to remote
|
- name: Copy files to remote
|
||||||
if: steps.detect.outputs.changed_envs != ''
|
if: steps.check.outputs.should_deploy == 'true'
|
||||||
uses: burnett01/rsync-deployments@7.0.2
|
uses: burnett01/rsync-deployments@7.0.2
|
||||||
with:
|
with:
|
||||||
switches: -az -r --del
|
switches: -az -r --del
|
||||||
@@ -53,6 +56,7 @@ jobs:
|
|||||||
remote_user: ${{ secrets.DEPLOY_USER }}
|
remote_user: ${{ secrets.DEPLOY_USER }}
|
||||||
remote_key: ${{ secrets.DEPLOY_KEY }}
|
remote_key: ${{ secrets.DEPLOY_KEY }}
|
||||||
- name: Deploy applications
|
- name: Deploy applications
|
||||||
|
if: steps.check.outputs.should_deploy == 'true'
|
||||||
uses: appleboy/ssh-action@v1
|
uses: appleboy/ssh-action@v1
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.DEPLOY_HOST }}
|
host: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
|||||||
Reference in New Issue
Block a user