actions/setup-python
actions/setup-python@v5 - latest version (2024/01/03)
GitHub - actions/setup-python: Set up your GitHub Actions workflow with a specific version of Python
Set up your GitHub Actions workflow with a specific version of Python - actions/setup-python
github.com
python-version (Optional) : python ๋ฒ์ ๋ช ์. (default: .python-version > pypy version)
- semver ๋ฒ์ ์ฌ์ฉ(์ ์์ ๋ฒ์ 2.0.0 ) ex) 3.11.4
- ๋ฒ์ ์
๋ ฅ์ ์ ์ ์ฌํญ
- ํ์ํ ํน์ ๋ฒ์ ์ Python ์ค์น ์ ๋ฒ์ ๋ณ ์ฃผ์ ๋ณ๊ฒฝ ์ฌํญ์ ๋ํด ์๊ด ์์ ๊ฒฝ์ฐ ์ฃผ, ๋ถ ๋ฒ์ ๋ฐ ํจ์น ๋ฒ์ (์: ์ฒ๋ผ ):3.7.6, 3.7.5 ๊ธฐ์
- semver์ ์ง์ ๋ ์ฌ๋ฌ ์ ํ์ ๋ฒ์ ์ฌ์ฉ (`>=3.9 <3.10`)
- check-latest : ์ต์ ๋ฒ์ ์ฌ์ฉ (default: false)
workflow_dispatch ๊ธฐ๋ฅ
์ํฌํ๋ก์ฐ๊ฐ ์๋์ผ๋ก ํธ๋ฆฌ๊ฑฐ๋๋๋ก ํ๋ ค๋ฉด workflow_dispatch ์ด๋ฒคํธ๋ฅผ ๊ตฌ์ฑํด์ผํ๋ค.
on: workflow_dispatch
์ํฌํ๋ก๋ฅผ ํธ๋ฆฌ๊ฑฐํ๋ ์ด๋ฒคํธ - GitHub Docs
GitHub์ ๋ํ ํน์ ์์ ์ด ์์ฝ๋ ์๊ฐ์ ๋ฐ์ํ๊ฑฐ๋ GitHub ์ธ๋ถ์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ ๋ ์คํ๋๋๋ก ์ํฌํ๋ก๋ฅผ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
docs.github.com
name: Action # Use tags to trigger the action
on:
workflow_dispatch:
inputs:
statement:
description: Question
required: true
default: "\"How is the weather?\""
jobs:
app-build:
name: ELIZA build on Ubuntu-latest
runs-on: ubuntu-latest
steps:
- name: Checkout & Set Environment Variables
uses: actions/checkout@v3
- name: Qustion ELIZA ${{ inputs.statement }}
run: |
cd $GITHUB_WORKSPACE
python action.py --statement ${{ inputs.statement }} >> answer_sheet.txt
- name: ELIZA Answer $GITHUB_ENV
run: |
echo "::group:: Result"
echo "Q: ${{ inputs.statement }}"
echo "A: $(cat answer_sheet.txt)"
formatter
Black formatter
- ์๋ Python PEP8 format ๊ต์ (๊ฐํน query๋ฌธ์ด๋ ์ฝ๋ \t ๋์ด์ฐ๊ธฐ ๋ฌธ์ ๋ก Error) → ๊ฐ์ ๋ณ๊ฒฝ
jobs:
black:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.9
- run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: |
black --check --verbose .
pull_request ์์ฑ
name: black-action
on: [push, pull_request]
jobs:
linter_name:
name: runner / black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."
- name: Create Pull Request
if: steps.action_black.outputs.is_formatted == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Format Python code with psf/black push"
commit-message: ":art: Format Python code with psf/black"
body: |
There appear to be some python formatting errors in ${{ github.sha }}. This pull request
uses the [psf/black](https://github.com/psf/black) formatter to fix these issues.
base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
branch: actions/black
ruff formatter
- Flake8๊ณผ black์ ๋์ฒดํ๊ธฐ ์ํด rust๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ python linter ์ค ๊ฐ์ฅ ๋น ๋ฆ
- check: linter check
- format: linter ์ ์ฉ
name: Apply Linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
args: 'check --diff'
- uses: chartboost/ruff-action@v1
with:
args: 'format --check'
docker setup buildx
- QEMU (optional) : ๋ค์ํ virtual env ์ง์ํ๋ ํ๋ก๊ทธ๋จ ์ฃผ๋ก ํน์ํ ํ๊ฒฝ (iot module)์์ ๋ง์ด ์ฌ์ฉ.
- Buildx : docker build ํ๊ฒฝ ๊ตฌ์ถ
jobs:
buildx:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Slack Webhook
Slack ๋ฉ์ธ์ง ๋ฐ์ก
[Custom CI Result]
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/slack-github-action@v1.24.0
with:
# For posting a rich message using Block Kit
payload: |
{
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
Secret Json
Secret Variable์ ์ฌ์ฉํ ๋ json format์ผ๋ก ๋ณ์๋ฅผ ์์ฑํ๋ฉด ๋ฌธ์์ด์ format์ ์ฝ์ ์ ์์ด error๊ฐ ๋จ.
์ด๋ฅผ ํผํ๊ธฐ ์ํด base64 string์ ์ฌ์ฉํด credential_file์ ์์ฑ
env:
PREFECT_API_KEY: ${{ secrets.PREFECT_API_KEY }}
PREFECT_API_URL: ${{ secrets.PREFECT_API_URL }}
BASE64: ${{ secrets.BASE64 }}
GCP_RESOURCE_REGION: ${{ secrets.GCP_RESOURCE_REGION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_ARTIFACT_REPOSITORY_NAME: ${{ secrets.GCP_ARTIFACT_REPOSITORY_NAME }}
FLOW_IMAGE_NAME: ${{ secrets.FLOW_IMAGE_NAME }}
# authenticating with Gcloud example
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.BASE64 }}
# authenticating with Docker example
- name: Build and push image to GAR
run: |
RAW_IMAGE=$GCP_RESOURCE_REGION-docker.pkg.dev/$GCP_PROJECT/$GCP_ARTIFACT_REPOSITORY_NAME/$FLOW_IMAGE_NAME
IMAGE_URI=$GCP_RESOURCE_REGION-docker.pkg.dev/$GCP_PROJECT/$GCP_ARTIFACT_REPOSITORY_NAME/$FLOW_IMAGE_NAME:$GITHUB_SHA
docker build -q \
--build-arg PREFECT_API_KEY=$PREFECT_API_KEY \
--build-arg PREFECT_API_URL=$PREFECT_API_URL \
--build-arg BASE64=$BASE64 \
-t $RAW_IMAGE \
-f ./Dockerfiles/flows.Dockerfile .
docker tag $RAW_IMAGE $IMAGE_URI
docker push $RAW_IMAGE
docker push $IMAGE_URI
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_OUTPUT
shell: bash
Using JSON in your GitHub Actions when authenticating with GCP
If you try to input raw JSON into your GitHub action, it’s likely that you’re going to be in for a few surprises. Especially if your JSON…
medium.com
Reference
https://github.com/peter-evans/create-pull-request
GitHub - peter-evans/create-pull-request: A GitHub action to create a pull request for changes to your repository in the actions
A GitHub action to create a pull request for changes to your repository in the actions workspace - peter-evans/create-pull-request
github.com
https://github.com/marketplace/actions/run-black-formatter
Run black formatter - GitHub Marketplace
Run the black formatter on your codebase to improve code review experience
github.com
[CI/CD] FastAPI ๋ฐฐํฌํ๊ธฐ - AWS EC2, Github Actions, Docker
fastAPI ์ react ๋ฅผ ์ด์ฉํ ์๋น์ค๋ฅผ ๋ค ์์ฑํ์ผ๋ ๋ฐฐํฌ๋ฅผ ํด์ผ์ง.AWS EC2 - Linux (๋น์ฐํ putty ๋ ํ์)Github Respository์กฐ๊ธ์๋ค ํ๊ฒ ์ง๋ง python ์ค์น ๋ชจ๋์ ๊ด๋ฆฌํ๋ requirements.txt ํ์ผ ๋ง๋ค๊ธฐ์คํ ์๋
velog.io
'๐งโ๐ป Develop' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Synology] openproject ๊ตฌ์ถ (0) | 2024.09.17 |
---|---|
Github ๊ณ์ ์ ํ (0) | 2024.08.19 |
์ค๋์ ํดํน์ ํฉ (1) (0) | 2024.07.09 |
indent : tab(ํญ, \t) or space(๊ณต๋ฐฑ, \s) (0) | 2024.05.08 |
[rsyslog] ๋ค์ ๋ง๋ rsyslogd: action 'action-2-builtin:omfile' resumed (module 'builtin:omfile') (0) | 2024.04.17 |