feat: add more push paths to workflows (#504) #1
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: Deploy Discord Bot Test | |
on: | |
push: | |
paths: | |
- apps/discord-bot/** | |
- command/** | |
- config/** | |
- db/** | |
- helper/** | |
- model/** | |
- platform/** | |
- service/** | |
- "go.mod" | |
- "go.sum" | |
branches: | |
- dev | |
pull_request: {} | |
permissions: | |
actions: write | |
contents: read | |
env: | |
REGISTRY: registry.fly.io | |
MAIN_APP_NAME: senchabot0728dc-cold-flower-2047 | |
jobs: | |
build: | |
name: Build | |
# only build/deploy dev branch on pushes | |
if: ${{ (github.ref == 'refs/heads/dev') && github.event_name == 'push' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Setup cache | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Fly Registry Auth | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: x | |
password: ${{ secrets.DISCORD_BOT_TEST_FLY_API }} | |
- name: Docker build | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./apps/discord-bot/Dockerfile | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.MAIN_APP_NAME }}:${{ github.ref_name }}-${{ github.sha }} | |
build-args: | | |
COMMIT_SHA=${{ github.sha }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
# This ugly bit is necessary if you don't want your cache to grow forever | |
# till it hits GitHub's limit of 5GB. | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: [build] | |
# only build/deploy dev branch on pushes | |
if: ${{ (github.ref == 'refs/heads/dev') && github.event_name == 'push' }} | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Deploy dev | |
if: ${{ github.ref == 'refs/heads/dev' }} | |
uses: superfly/[email protected] | |
with: | |
args: "deploy --app ${{ env.MAIN_APP_NAME }} --image ${{ env.REGISTRY }}/${{ env.MAIN_APP_NAME }}:${{ github.ref_name }}-${{ github.sha }} --config ./apps/discord-bot/fly.toml" | |
env: | |
FLY_API_TOKEN: ${{ secrets.DISCORD_BOT_TEST_FLY_API }} | |
# - name: Deploy Production | |
# if: ${{ github.ref == 'refs/heads/main' }} | |
# uses: superfly/[email protected] | |
# with: | |
# args: "deploy --image ${{ env.REGISTRY }}/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}" | |
# env: | |
# FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} |