14줄의 코드로 로또 구매 자동화 하기

HYUNGU, KANG·2023년 6월 19일
13
post-thumbnail

해당 프로젝트는 깃허브 정책 위반으로 더이상 유지되지 않습니다.
히스토리가 궁금하신 분들은 댓글을 참고해주시기 바랍니다!


https://github.com/rich-automation/lotto-action 을 사용하기 위한 가이드입니다.
이미 GitHub Actions 를 잘 아시는 분이면 템플릿 레포 를 참고해주세요

자동 구매 설정하기

저장소 생성

깃허브 계정으로 로그인을 한 뒤, 우측 상단의 + 버튼 > New repository 를 눌러서 새로운 저장소를 생성합니다.

워크플로우 파일 생성

저장소가 생성됐으면 이제 일정 시간마다 자동으로 실행될 워크플로우 파일을 생성합니다.
creating a new file 을 클릭하세요.

상단에 Name your file 에는 .github/workflows/cron.yml 를 입력하고
파일 내용에는 아래의 스크립트를 붙여넣은 뒤, Commit changes 버튼을 눌러서 파일을 생성합니다.

name: Lotto purchase (cron)
on:
  schedule:
    # 매 주 일요일 오전 7시, Github Actions 에서는 UTC 기준으로 실행됨
    # https://elmah.io/tools/cron-parser/
    - cron: '0 22 * * 6'
jobs:
  run-actions:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: rich-automation/lotto-action@latest
        with:
          id: ${{ secrets.ID }}
          pwd: ${{ secrets.PASSWORD }}
          token: ${{ secrets.GITHUB_TOKEN }}

파일이 잘 생성됐으면 아래 스크린샷처럼 확인할 수 있습니다.

권한 및 아이디/패스워드 설정

이제 저장소에 권한 및 아이디/패스워드를 설정하기 위해서, 가장 상단의 Settings 메뉴로 이동합니다.

Actions

GITHUB_TOKEN 시크릿의 권한 설정을 위해서 좌측의 메뉴에서 Actions > General 을 클릭하고
Workflow permissions > Read and write permissions 에 체크합니다.

Secrets

좌측의 메뉴에서 Secrets and variables > Actions 을 클릭하고
New repository secret 을 클릭합니다.

시크릿에는 아이디와 패스워드를 입력합니다. (GITHUB_TOKEN 는 자동으로 생성됩니다.)


이제 모든 설정이 끝났습니다.
이제 매주 일요일 오전 7시마다, 해당 레포에서 당첨 내역을 자동으로 확인하고 로또를 구매합니다.
*동행복권 아이디에는 예치금이 충전되어 있어야 구매가 정상적으로 이루어집니다.


기능 알아보기

구매 내역 관리

로또를 구매하면 저장소의 이슈에 구매 내역을 기록합니다.
구매 내역에는 구매 일자, 회차, 로또 번호, 로또 당첨조회 링크가 저장됩니다.

당첨 조회

구매 내역에서 당첨 조회가 안된 이슈들을 대상으로 당첨 조회를 진행합니다.

  • 당첨이 안된 경우 이슈의 라벨을 ☠️ 로 업데이트 하고 이슈를 닫습니다.
  • 당첨이 된 경우 이슈의 라벨을 🎊 🥇 와 같이 당첨된 등수로 업데이트하고, 레포의 주인을 멘션하여 알려줍니다.
profile
JavaScript, TypeScript and React-Native

12개의 댓글

comment-user-thumbnail
2024년 3월 10일

이거 좋네요. 저도 비슷한 라이브러리를 만들어서 사용 중인데, issue 를 구매티켓처럼 활용하는건 정말 재밌는 아이디어같아요. 많이 배워갑니다.

1개의 답글
comment-user-thumbnail
2024년 3월 12일

엇.. 액션 사용이 안되는데 혹시 아카이빙 하신건가요?

1개의 답글
comment-user-thumbnail
2024년 3월 12일

기존에 액션을 사용하다가 GitHub에 의해서 레포지토리가 비활성화 되었습니다.
위의 관련 댓글을 확인하였고 상황을 파악했습니다만, GitHub의 어떤 정책에 의해 abuse로 판단 된것인지 궁금합니다 :)

1개의 답글
comment-user-thumbnail
2024년 3월 12일

제 견해를 담은 항소 전문입니다. 자동화된 다양한 작업들을 깃허브 액션으로 수행하는데 있어서
좀 더 상세한 가이드가 내려오면 추가적으로 업데이트 하도록 하겠습니다~

Dear esteemed GitHub staff,

I hope this message finds you well. Before proceeding with my appeal, I would like to assert that I am a devoted user of GitHub Actions and not a malicious actor. To support this claim, I would like to highlight several GitHub Actions I have contributed to:
- https://github.com/bang9/issue-to-readme
- https://github.com/sendbird/release-automation-action

Over the years, I have utilized GitHub Actions not only for CI/CD purposes but also to automate various tasks, considering it as a versatile platform for automation. Examples abound where GitHub Actions have been employed beyond traditional CI/CD roles.

For instance:
- https://github.com/maxam2017/productive-box
- https://github.com/githubocto/flat
- https://github.com/marketplace/actions/algolia-crawler-automatic-crawl

These examples, akin to my own lotto-action, utilize web scraping or crawling to automate specific tasks via GitHub Actions.
Moreover, like many others, the purpose of these actions primarily involves gathering personal data or generating statistics.

It's worth noting that lotto-action doesn't engage in resource-intensive tasks akin to crypto mining. It simply scrapes data from a website weekly (i.e., purchase and fetching purchased lottery numbers) and automates the verification of winning numbers via API calls.
Additionally, this data, like that of other actions, is managed using GitHub's issue feature, constituting an intriguing experiment.

If you'd like to see how the actions actually operate and what their execution schedule and timing are, please feel free to review the following repositories:
- https://github.com/bang9/lotto-purchase/issues
- https://github.com/bang9/lotto-purchase/actions

Based on these reasons, I humbly appeal for the reactivation of the repository.

However, should any aspects of the repository violate policies, I kindly request guidance on identifying these infractions in comparison to the referenced examples. I am more than willing to make necessary improvements and refactorings accordingly.
Your positive consideration of this request would be greatly appreciated.

Thank you for your attention and understanding.

Best regards,
Airen Kang.
1개의 답글
comment-user-thumbnail
2024년 3월 15일

깃허브로부터 아래의 두가지 약관을 위반하였다는 답변을 받았습니다.

  • using GitHub as a platform for propagating abuse on other platforms
  • any activity that places a burden on our servers, where that burden is disproportionate to the benefits provided to users (for example, don't use Actions as a content delivery network or as part of a serverless application, but a low benefit Action could be ok if it’s also low burden)

이에 대해서 확인한 결과 동행복권 사이트의 서비스 이용 약관에 "회사가 제공하는 서비스 이용방법에 의하지 아니하고 비정상적인 방법으로 서비스를 이용하거나 시스템에 접근하는 행위" 가 포함된것을 확인하였습니다. 이 부분에 해당하기 때문에 항소 티켓은 닫을 예정입니다.

해당 프로젝트는 구매를 지원하는 방식으로는 더이상 유지되지 않을 예정이며, 구매를 제외한 기존의 기능들과 몇가지 추가 기능을 포함하여 새로운 방향으로 프로젝트를 개선 할 예정입니다.

감사합니다.

1개의 답글