91 lines
4.3 KiB
YAML
91 lines
4.3 KiB
YAML
name: Release production images
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: ["CI"]
|
|
branches: [main]
|
|
types: [completed]
|
|
|
|
jobs:
|
|
publish-images:
|
|
if: >-
|
|
gitea.event.workflow_run.conclusion == 'success' &&
|
|
gitea.event.workflow_run.event == 'push' &&
|
|
gitea.event.workflow_run.head_branch == 'main'
|
|
runs-on: akyldash-ci
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ gitea.event.workflow_run.head_sha }}
|
|
- name: Verify successful CI source before using registry credentials
|
|
env:
|
|
SOURCE_WORKFLOW: ${{ gitea.event.workflow.name }}
|
|
SOURCE_WORKFLOW_PATH: ${{ gitea.event.workflow_run.path }}
|
|
SOURCE_EVENT: ${{ gitea.event.workflow_run.event }}
|
|
SOURCE_CONCLUSION: ${{ gitea.event.workflow_run.conclusion }}
|
|
SOURCE_BRANCH: ${{ gitea.event.workflow_run.head_branch }}
|
|
SOURCE_RUN_ID: ${{ gitea.event.workflow_run.id }}
|
|
SOURCE_SHA: ${{ gitea.event.workflow_run.head_sha }}
|
|
SOURCE_REPOSITORY: ${{ gitea.event.repository.full_name }}
|
|
run: python3 infra/deploy/release_handoff.py validate-ci-source
|
|
- name: Require explicitly configured Gitea registry credentials
|
|
env:
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
run: |
|
|
test -n "$REGISTRY_USERNAME" || { echo 'REGISTRY_USERNAME repository secret is required'; exit 1; }
|
|
test -n "$REGISTRY_PASSWORD" || { echo 'REGISTRY_PASSWORD repository secret is required'; exit 1; }
|
|
- name: Build and publish backend image
|
|
uses: ./.gitea/actions/kaniko-push
|
|
env:
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
with:
|
|
workspace: ${{ github.workspace }}
|
|
dockerfile: deploy/production/Dockerfile.backend
|
|
destination: git.vakanaut.ru/admin/akyldash/backend:${{ gitea.event.workflow_run.head_sha }}-${{ gitea.run_id }}
|
|
digest_file: ${{ github.workspace }}/release/backend.digest
|
|
- name: Build and publish OpenSearch image
|
|
uses: ./.gitea/actions/kaniko-push
|
|
env:
|
|
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
|
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
|
with:
|
|
workspace: ${{ github.workspace }}
|
|
dockerfile: deploy/production/Dockerfile.opensearch
|
|
destination: git.vakanaut.ru/admin/akyldash/opensearch:${{ gitea.event.workflow_run.head_sha }}-${{ gitea.run_id }}
|
|
digest_file: ${{ github.workspace }}/release/opensearch.digest
|
|
- name: Create and validate release descriptor
|
|
run: |
|
|
python3 infra/deploy/create_release_manifest.py \
|
|
--repository admin/akyldash \
|
|
--commit '${{ gitea.event.workflow_run.head_sha }}' \
|
|
--run-id '${{ gitea.run_id }}' \
|
|
--source-run-id '${{ gitea.event.workflow_run.id }}' \
|
|
--backend-digest release/backend.digest \
|
|
--opensearch-digest release/opensearch.digest \
|
|
--output release/release-manifest.json
|
|
python3 infra/deploy/validate_release.py release/release-manifest.json \
|
|
--policy infra/deploy/release-policy.json
|
|
(cd release && sha256sum release-manifest.json > release-manifest.json.sha256)
|
|
- id: descriptor
|
|
name: Record release descriptor digest
|
|
run: |
|
|
(cd release && sha256sum -c release-manifest.json.sha256)
|
|
digest=$(sha256sum release/release-manifest.json)
|
|
digest=${digest%% *}
|
|
printf 'descriptor_sha256=%s\n' "$digest" >> "$GITEA_OUTPUT"
|
|
- name: Upload verified release descriptor
|
|
uses: https://gitea.com/actions/gitea-upload-artifact@055b8b3f04a4a7ed853f2c6ab04256f83e4874dc
|
|
with:
|
|
name: release-descriptor-${{ gitea.run_id }}-${{ steps.descriptor.outputs.descriptor_sha256 }}
|
|
path: |
|
|
release/release-manifest.json
|
|
release/release-manifest.json.sha256
|
|
if-no-files-found: error
|
|
retention-days: 90
|
|
- name: Confirm uploaded release descriptor
|
|
run: |
|
|
(cd release && sha256sum -c release-manifest.json.sha256)
|
|
echo 'Release descriptor and checksum are available as this run artifact.'
|