diff --git a/.github/workflows/beta-build.yml b/.github/workflows/beta-build.yml deleted file mode 100644 index 4812e4b..0000000 --- a/.github/workflows/beta-build.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: beta - -on: - push: - branches: - - dev - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push (booth-checker) - uses: docker/build-push-action@v6 - with: - push: true - file: ./docker/booth-checker/Dockerfile - tags: ogunarmaya/booth-checker:beta - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build and push (booth-discord) - uses: docker/build-push-action@v6 - with: - push: true - file: ./docker/booth-discord/Dockerfile - tags: ogunarmaya/booth-discord:beta - cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml deleted file mode 100644 index dfee743..0000000 --- a/.github/workflows/dev-build.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: dev - -on: - pull_request: - branches: - - dev - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push (booth-checker) - uses: docker/build-push-action@v6 - with: - push: true - file: ./docker/booth-checker/Dockerfile - tags: ogunarmaya/booth-checker:dev - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build and push (booth-discord) - uses: docker/build-push-action@v6 - with: - push: true - file: ./docker/booth-discord/Dockerfile - tags: ogunarmaya/booth-discord:dev - cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/develop-build.yml b/.github/workflows/develop-build.yml new file mode 100644 index 0000000..1d524e7 --- /dev/null +++ b/.github/workflows/develop-build.yml @@ -0,0 +1,95 @@ +name: develop + +on: + push: + branches: + - develop + +env: + REGISTRY: ghcr.io + IMAGE_NAME_BOOTH_CHECKER: ${{ github.repository_owner }}/booth-checker + IMAGE_NAME_BOOTH_DISCORD: ${{ github.repository_owner }}/booth-discord + +jobs: + build-and-push-images: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} + + # ======================= + # booth-checker + # ======================= + - name: Extract metadata (booth-checker) + id: meta_booth_checker + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_CHECKER }} + tags: | + type=ref,event=branch + type=sha + + - name: Build and push Docker image (booth-checker) + id: push_booth_checker + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/booth-checker/Dockerfile + push: true + tags: ${{ steps.meta_booth_checker.outputs.tags }} + labels: ${{ steps.meta_booth_checker.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Generate artifact attestation (booth-checker) + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_CHECKER }} + subject-digest: ${{ steps.push_booth_checker.outputs.digest }} + push-to-registry: true + + # ======================= + # booth-discord + # ======================= + - name: Extract metadata (booth-discord) + id: meta_booth_discord + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_DISCORD }} + tags: | + type=ref,event=branch + type=sha + + - name: Build and push Docker image (booth-discord) + id: push_booth_discord + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/booth-discord/Dockerfile + push: true + tags: ${{ steps.meta_booth_discord.outputs.tags }} + labels: ${{ steps.meta_booth_discord.outputs.labels }} + cache-from: type=gha + + - name: Generate artifact attestation (booth-discord) + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_DISCORD }} + subject-digest: ${{ steps.push_booth_discord.outputs.digest }} + push-to-registry: true \ No newline at end of file diff --git a/.github/workflows/latest-build.yml b/.github/workflows/latest-build.yml index db04d60..460878e 100644 --- a/.github/workflows/latest-build.yml +++ b/.github/workflows/latest-build.yml @@ -3,39 +3,98 @@ name: latest on: push: tags: - - 'v*' + - 'v*' # v1.0.0 같은 태그 푸시될 때만 실행 + +env: + REGISTRY: ghcr.io + IMAGE_NAME_BOOTH_CHECKER: ${{ github.repository_owner }}/booth-checker + IMAGE_NAME_BOOTH_DISCORD: ${{ github.repository_owner }}/booth-discord jobs: docker-build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - name: Checkout repository + uses: actions/checkout@v5 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # ======================= + # booth-checker + # ======================= + - name: Extract metadata (booth-checker) + id: meta_booth_checker + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_CHECKER }} + tags: | + type=raw,value=latest + type=ref,event=tag - name: Build and push (booth-checker) + id: push_booth_checker uses: docker/build-push-action@v6 with: - push: true + context: . file: ./docker/booth-checker/Dockerfile - tags: ogunarmaya/booth-checker:latest + push: true + tags: ${{ steps.meta_booth_checker.outputs.tags }} + labels: ${{ steps.meta_booth_checker.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - + + - name: Generate artifact attestation (booth-checker) + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_CHECKER }} + subject-digest: ${{ steps.push_booth_checker.outputs.digest }} + push-to-registry: true + + # ======================= + # booth-discord + # ======================= + - name: Extract metadata (booth-discord) + id: meta_booth_discord + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_DISCORD }} + tags: | + type=raw,value=latest + type=ref,event=tag + - name: Build and push (booth-discord) + id: push_booth_discord uses: docker/build-push-action@v6 with: - push: true + context: . file: ./docker/booth-discord/Dockerfile - tags: ogunarmaya/booth-discord:latest + push: true + tags: ${{ steps.meta_booth_discord.outputs.tags }} + labels: ${{ steps.meta_booth_discord.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - + + - name: Generate artifact attestation (booth-discord) + uses: actions/attest-build-provenance@v3 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BOOTH_DISCORD }} + subject-digest: ${{ steps.push_booth_discord.outputs.digest }} + push-to-registry: true + publish-release: runs-on: ubuntu-latest needs: docker-build diff --git a/README.md b/README.md index 453d636..4383939 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # BoothChecker [![latest](https://github.com/MAX-FLAVOR/BoothChecker/actions/workflows/latest-build.yml/badge.svg)](https://github.com/MAX-FLAVOR/BoothChecker/actions/workflows/latest-build.yml) -[![dev](https://github.com/MAX-FLAVOR/BoothChecker/actions/workflows/dev-build.yml/badge.svg)](https://github.com/MAX-FLAVOR/BoothChecker/actions/workflows/dev-build.yml) +[![develop](https://github.com/MAX-FLAVOR/BoothChecker/actions/workflows/develop-build.yml/badge.svg)](https://github.com/MAX-FLAVOR/BoothChecker/actions/workflows/develop-build.yml) *** ### Docker-Compose diff --git a/booth_discord/__main__.py b/booth_discord/__main__.py index 351ad22..b305d85 100644 --- a/booth_discord/__main__.py +++ b/booth_discord/__main__.py @@ -37,12 +37,13 @@ def main(): # Read configuration values discord_bot_token = config_json['discord_bot_token'] selenium_url = config_json['selenium_url'] + fbx_only = config_json['fbx_only'] # Initialize database and bot booth_crawler = booth_module.BoothCrawler(selenium_url) postgres_config = dict(config_json['postgres']) booth_db = booth_sql.BoothPostgres(postgres_config, booth_crawler, logger) - bot = booth_discord.DiscordBot(booth_db, logger) + bot = booth_discord.DiscordBot(booth_db, logger, fbx_only) bot.run(discord_bot_token) if __name__ == "__main__": diff --git a/booth_discord/booth_discord.py b/booth_discord/booth_discord.py index 531122f..842c2ff 100644 --- a/booth_discord/booth_discord.py +++ b/booth_discord/booth_discord.py @@ -7,12 +7,13 @@ import asyncio class DiscordBot(commands.Bot): - def __init__(self, booth_db, logger, *args, **kwargs): + def __init__(self, booth_db, logger, fbx_only, *args, **kwargs): intents = discord.Intents.default() intents.message_content = True super().__init__(command_prefix="/", intents=intents, *args, **kwargs) self.booth_db = booth_db self.logger = logger + self.fbx_only = fbx_only self.embed_message = None # on_ready에서 초기화 예정 self.app = Quart(__name__) # Quart 앱 초기화 self.setup_commands() @@ -48,7 +49,7 @@ async def booth(interaction: discord.Interaction, cookie: str): @app_commands.describe(order_number="수동으로 주문 번호를 입력해야 할 때에 사용") @app_commands.describe(intent_encoding="아이템 이름의 인코딩 방식을 입력해주세요 (기본값: shift_jis)") @app_commands.describe(summary_this="업데이트 내용 요약 (기본값: True)") - @app_commands.describe(fbx_only="FBX 변경점만 확인 (기본값: False)") + @app_commands.describe(fbx_only=f'FBX 변경점만 확인 (기본값: {str(self.fbx_only)})') async def item_add( interaction: discord.Interaction, item_number: str, @@ -56,7 +57,7 @@ async def item_add( order_number: str = None, intent_encoding: str = "shift_jis", summary_this: bool = True, - fbx_only: bool = False + fbx_only: bool = self.fbx_only ): try: await interaction.response.defer(ephemeral=True) diff --git a/config-sample.json b/config-sample.json index dc6d091..84a50b8 100644 --- a/config-sample.json +++ b/config-sample.json @@ -1,6 +1,7 @@ { "dry_run": false, "refresh_interval": 600, + "fbx_only": false, "logging": { "syslog": { "enabled": false,