Merge pull request #246 from bdach/timeouts #159
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: Build and publish | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
env: | |
PRODUCTION_TRACK: ${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-') && 'production') || (github.ref_type == 'branch' && github.ref_name == 'master' && 'staging') || '' }} | |
jobs: | |
push_to_registry: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
pppy/osu-server-spectator | |
# generate Docker tags based on the following events/attributes | |
# on tag event: tag using git tag, and as latest if the tag doesn't contain hyphens (pre-releases) | |
# on push event: tag using git sha, branch name and as latest-dev | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && !contains(github.ref_name, '-') }} | |
type=raw,value=latest-dev,enable=${{ github.ref_type == 'branch' && github.ref_name == 'master' }} | |
type=raw,value=${{ github.ref_name }} | |
type=raw,value=${{ github.sha }},enable=${{ github.ref_type == 'branch' }} | |
flavor: | | |
latest=false | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- | |
name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./osu.Server.Spectator | |
file: ./osu.Server.Spectator/Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
notify_pending_production_deploy: | |
if: ${{ github.ref_type == 'tag' && !contains(github.ref_name, '-') }} | |
runs-on: ubuntu-latest | |
needs: | |
- push_to_registry | |
steps: | |
- | |
name: Submit pending deployment notification | |
run: | | |
export TITLE="Pending osu-server-spectator Production Deployment: $GITHUB_REF_NAME" | |
export URL="https://github.com/ppy/osu-server-spectator/actions/runs/$GITHUB_RUN_ID" | |
export DESCRIPTION="Docker image was built for tag $GITHUB_REF_NAME and awaiting approval for production deployment: | |
[View Workflow Run]($URL)" | |
export ACTOR_ICON="https://avatars.githubusercontent.com/u/$GITHUB_ACTOR_ID" | |
BODY="$(jq --null-input '{ | |
"embeds": [ | |
{ | |
"title": env.TITLE, | |
"color": 15098112, | |
"description": env.DESCRIPTION, | |
"url": env.URL, | |
"author": { | |
"name": env.GITHUB_ACTOR, | |
"icon_url": env.ACTOR_ICON | |
} | |
} | |
] | |
}')" | |
curl \ | |
-H "Content-Type: application/json" \ | |
-d "$BODY" \ | |
"${{ secrets.DISCORD_INFRA_WEBHOOK_URL }}" | |
trigger_deploy: | |
if: ${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-')) || (github.ref_type == 'branch' && github.ref_name == 'master') }} | |
runs-on: ubuntu-latest | |
needs: | |
- push_to_registry | |
environment: ${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-') && 'production') || 'staging' }} | |
steps: | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# the "Create Sentry release" step relies on accessing git history | |
# to find the SHA of the previous release and set the range of new commits in the release being deployed. | |
# do a full clone rather than a shallow one to allow it to do that. | |
fetch-depth: 0 | |
- | |
name: Repository Dispatch | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.KUBERNETES_CONFIG_REPO_ACCESS_TOKEN }} | |
repository: ppy/osu-kubernetes-config | |
event-type: ${{ env.PRODUCTION_TRACK == 'staging' && 'dev-ppy-sh-deploy' || 'osu-server-spectator-deploy' }} | |
client-payload: |- | |
${{ env.PRODUCTION_TRACK == 'staging' && format('{{ "values": {{ "osu-server-spectator": {{ "image": {{ "tag": "{0}" }} }} }} }}', github.sha) || format('{{ "dockerTag": "{0}" }}', github.ref_name) }} | |
- | |
name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ppy | |
SENTRY_PROJECT: osu-server-spectator | |
SENTRY_URL: https://sentry.ppy.sh/ | |
with: | |
environment: ${{ env.PRODUCTION_TRACK }} | |
version: osu-server-spectator@${{ github.ref_type == 'branch' && github.sha || github.ref_type == 'tag' && github.ref_name }} |