Skip to content

Commit 89337a3

Browse files
committed
updated deploy-production.yaml ver 2
1 parent d5f1c08 commit 89337a3

1 file changed

Lines changed: 58 additions & 29 deletions

File tree

.github/workflows/deploy-production.yaml

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ jobs:
122122
# Backup текущей конфигурации если есть
123123
if [ -f docker-compose.yml ]; then
124124
cp docker-compose.yml $BACKUP_DIR/
125-
docker-compose ps > $BACKUP_DIR/containers.txt
126125
echo "Configuration backed up"
127126
fi
128127
@@ -290,31 +289,61 @@ jobs:
290289
echo "Health check completed successfully"
291290
292291
create-deployment-record:
293-
needs: health-check
294-
runs-on: ubuntu-latest
295-
permissions:
296-
contents: read
297-
deployments: write
298-
if: success()
299-
300-
steps:
301-
- name: Create GitHub Deployment
302-
uses: actions/github-script@v7
303-
with:
304-
script: |
305-
await github.rest.repos.createDeployment({
306-
owner: context.repo.owner,
307-
repo: context.repo.repo,
308-
ref: '${{ needs.deploy.outputs.commit }}',
309-
environment: 'production',
310-
required_contexts: [],
311-
auto_merge: false,
312-
description: 'Deployed version ${{ needs.deploy.outputs.commit }} with health check passed'
313-
});
314-
315-
- name: Deployment Success Notification
316-
run: |
317-
echo "Production deployment completed successfully!"
318-
echo "Version: ${{ needs.deploy.outputs.commit }}"
319-
echo "Health check: PASSED"
320-
echo "Deployment record created in GitHub"
292+
needs: health-check
293+
runs-on: ubuntu-latest
294+
permissions:
295+
contents: read
296+
deployments: write
297+
if: success()
298+
299+
steps:
300+
- name: Get commit from deploy job
301+
id: get-commit
302+
run: |
303+
# Получаем commit из предыдущей job через needs
304+
COMMIT="${{ needs.deploy.outputs.commit }}"
305+
306+
# Если пустой, пробуем получить из check-ci-status
307+
if [ -z "$COMMIT" ]; then
308+
COMMIT="${{ needs.check-ci-status.outputs.commit }}"
309+
fi
310+
311+
# Если все еще пустой, получаем последний коммит из main
312+
if [ -z "$COMMIT" ]; then
313+
git clone --depth 1 https://github.com/${{ github.repository }}.git temp-repo
314+
cd temp-repo
315+
COMMIT=$(git rev-parse origin/main)
316+
cd .. && rm -rf temp-repo
317+
fi
318+
319+
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
320+
echo "Using commit: $COMMIT"
321+
322+
- name: Create GitHub Deployment
323+
uses: actions/github-script@v7
324+
with:
325+
script: |
326+
const commit = '${{ steps.get-commit.outputs.commit }}';
327+
328+
if (!commit) {
329+
throw new Error('Commit hash is empty!');
330+
}
331+
332+
console.log(`Creating deployment for commit: ${commit}`);
333+
334+
await github.rest.repos.createDeployment({
335+
owner: context.repo.owner,
336+
repo: context.repo.repo,
337+
ref: commit,
338+
environment: 'production',
339+
required_contexts: [],
340+
auto_merge: false,
341+
description: `Deployed version ${commit} with health check passed`
342+
});
343+
344+
- name: Deployment Success Notification
345+
run: |
346+
echo "Production deployment completed successfully!"
347+
echo "Version: ${{ steps.get-commit.outputs.commit }}"
348+
echo "Health check: PASSED"
349+
echo "Deployment record created in GitHub"

0 commit comments

Comments
 (0)