production #625
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: Extract Quicklisp dist data | |
on: [deployment] | |
jobs: | |
extract: | |
name: Extract data | |
runs-on: ubuntu-latest | |
concurrency: | |
group: deploy-production | |
cancel-in-progress: true | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Set up gcloud Cloud SDK environment | |
uses: google-github-actions/setup-gcloud@v0.2.0 | |
with: | |
project_id: quickdocs | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
export_default_credentials: true | |
- name: Build Docker image | |
run: | | |
make docker_image | |
- name: Push Docker image | |
run: | | |
image_name=ghcr.io/quickdocs/quicklisp-dist-all | |
version=$(docker images ghcr.io/quickdocs/quicklisp-dist-all | tail -n +2 | head -n 1 | awk '{ print $2 }') | |
docker push "$image_name:$version" | |
- name: Get deployment ID | |
id: deployment | |
run: echo "::set-output name=id::$(jq -r '.deployment.id' $GITHUB_EVENT_PATH)" | |
- name: Get the Quicklisp version | |
id: quicklisp | |
run: echo "::set-output name=version::$(make quicklisp_version)" | |
- name: Extract the dist data | |
env: | |
BUCKET_BASE_URL: https://storage.googleapis.com/quickdocs-dist | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEPLOYMENT_ID: ${{ steps.deployment.outputs.id }} | |
run: | | |
echo "Deployment ID: $DEPLOYMENT_ID" | |
# Change the deployment status to 'in_progress' | |
github_run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
make github_deployment_status \ | |
deployment_id=$DEPLOYMENT_ID \ | |
description="Start extracting the library data from a Quicklisp dist." \ | |
state=in_progress \ | |
log_url=$github_run_url | |
# Get a deployment | |
curl -s -H 'Accept: application/vnd.github.v3+json' \ | |
https://api.github.com/repos/${GITHUB_REPOSITORY}/deployments/${DEPLOYMENT_ID} \ | |
> github_deployment | |
extract_target=$(jq -r '.payload.target' github_deployment) | |
if [ "$extract_target" = "all" ]; then | |
EXTRACT_ALL=1 | |
fi | |
# Extract | |
make generate-index extract EXTRACT_ALL=${EXTRACT_ALL} | |
- name: Upload to GCS | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEPLOYMENT_ID: ${{ steps.deployment.outputs.id }} | |
run: | | |
if [ -d ./output ]; then | |
github_run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
make github_deployment_status \ | |
deployment_id=$DEPLOYMENT_ID \ | |
description="Uploading the artifacts to the storage server." \ | |
state=in_progress \ | |
log_url=$github_run_url | |
# Upload | |
make upload | |
fi | |
- name: Change the state of the deployment to 'success' | |
if: success() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEPLOYMENT_ID: ${{ steps.deployment.outputs.id }} | |
QUICKLISP_VERSION: ${{ steps.quicklisp.outputs.version }} | |
run: | | |
github_run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
make github_deployment_status \ | |
deployment_id=$DEPLOYMENT_ID \ | |
description="Successfully extracted the library data." \ | |
state=success \ | |
log_url=$github_run_url \ | |
environment_url="https://storage.googleapis.com/quickdocs-dist/quicklisp/$QUICKLISP_VERSION/info.json" | |
- name: Change the state of the deployment to 'error' | |
if: failure() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEPLOYMENT_ID: ${{ steps.deployment.outputs.id }} | |
run: | | |
github_run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
make github_deployment_status \ | |
deployment_id=$DEPLOYMENT_ID \ | |
description="Error when extracting/uploading the library data." \ | |
state=error \ | |
log_url=$github_run_url | |
- name: Finalize the deployment status | |
if: always() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEPLOYMENT_ID: ${{ steps.deployment.outputs.id }} | |
run: | | |
sleep 3 | |
DEPLOYMENT_ID=${DEPLOYMENT_ID:-$(jq -r '.deployment.id' $GITHUB_EVENT_PATH)} | |
state=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$DEPLOYMENT_ID/statuses | jq -r '.[0].state') | |
echo "The deployment status is '$state'" | |
case "$state" in | |
success|failure|error) | |
;; | |
*) | |
github_run_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" | |
make github_deployment_status \ | |
deployment_id=$DEPLOYMENT_ID \ | |
description="Canceled the extraction." \ | |
state=failure \ | |
log_url=$github_run_url | |
;; | |
esac |