-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3709b19
commit 369f801
Showing
10 changed files
with
170 additions
and
192 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
types: [opened, synchronize, reopened] | ||
push: | ||
branches: [master] | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: "${{ github.workflow }}-${{ github.ref }}" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
action: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: facebook-post-action | ||
uses: ./ | ||
with: | ||
access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }} | ||
fail_on_error: true | ||
message: | | ||
${{ github.event.repository.name }} - ${{ github.ref_name }} test | ||
page_id: ${{ secrets.FACEBOOK_PAGE_ID }} | ||
url: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} | ||
|
||
release: | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
needs: | ||
# - pytest | ||
- action | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Release | ||
id: setup-release | ||
uses: LizardByte/setup-release-action@v2024.919.143601 | ||
with: | ||
github_token: ${{ secrets.GH_BOT_TOKEN }} | ||
|
||
- name: Create Release | ||
id: action | ||
uses: LizardByte/create-release-action@v2024.919.143026 | ||
with: | ||
allowUpdates: false | ||
artifacts: '' | ||
body: ${{ steps.setup-release.outputs.release_body }} | ||
generateReleaseNotes: ${{ steps.setup-release.outputs.release_generate_release_notes }} | ||
name: ${{ steps.setup-release.outputs.release_tag }} | ||
prerelease: true | ||
tag: ${{ steps.setup-release.outputs.release_tag }} | ||
token: ${{ secrets.GH_BOT_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM python:3.12-alpine3.18 AS base | ||
|
||
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel | ||
|
||
COPY . /app | ||
|
||
WORKDIR /app | ||
RUN python -m pip install --no-cache-dir --upgrade -r requirements.txt | ||
|
||
# github will mount the `GITHUB_WORKSPACE` directory to /github/workspace | ||
# https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#workdir | ||
|
||
ENTRYPOINT ["python", "/app/action/main.py"] |
This file was deleted.
Oops, something went wrong.
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
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# standard imports | ||
import os | ||
import sys | ||
|
||
# lib imports | ||
from dotenv import load_dotenv | ||
import requests | ||
|
||
load_dotenv() | ||
|
||
# inputs | ||
ACCESS_TOKEN = os.environ['INPUT_ACCESS_TOKEN'] | ||
MESSAGE = os.environ['INPUT_MESSAGE'] | ||
PAGE_ID = os.environ['INPUT_PAGE_ID'] | ||
URL = os.getenv('INPUT_URL', None) | ||
FAIL_ON_ERROR = os.getenv('INPUT_FAIL_ON_ERROR', 'true') | ||
|
||
# constants | ||
FACEBOOK_API_END = f'https://graph.facebook.com/{PAGE_ID}/feed' | ||
|
||
|
||
def main(): | ||
facebook_api_data = { | ||
'message': MESSAGE, | ||
'access_token': ACCESS_TOKEN, | ||
} | ||
if URL: | ||
facebook_api_data['link'] = URL | ||
|
||
r = requests.post(url=FACEBOOK_API_END, json=facebook_api_data) | ||
|
||
result = r.json() | ||
|
||
if 'error' not in result: | ||
print('Post successful') | ||
else: | ||
print('Post error:') | ||
print(result) | ||
if FAIL_ON_ERROR.lower() == 'true': | ||
print('Failing the workflow') | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() # pragma: no cover |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.