Reputation: 90
Maybe there is a similar question or solution in stackoverflow or google, but I tried several methods, provided in the Interne, but it didn't help for me. Because I started to learn CI/CD only today, I am asking for a help with my CI/CD issue.
python-publish.yml (pipeline):
name: Python Package
on:
push:
branches: [ main ]
env:
CI: true
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ 3.8 ]
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Initialize Python 3.8
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python-version}}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Check if Docker is installed
run: docker run hello-world
- name: Push to Docker Hub
uses: docker/build-push-action@v3
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
tags: latest
Dockerfile (maybe you will need it):
FROM python:3.8
# Set environment variables
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
#ENV MYSQL_DATABASE=<YOUR_DATABASE_NAME>
#ENV MYSQL_USER=<YOUR_USERNAME>
#ENV MYSQL_PASSWORD=<YOUR_PASSWORD>
#ENV MYSQL_HOST=<YOUR_HOST>
#ENV MYSQL_PORT=<YOUR_PORT>
# Create and set working directory
WORKDIR /app
# Copy requirements file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Expose port 80
EXPOSE 80
# Run the application
CMD ["flask", "run", "--host=0.0.0.0", "--port=80"]
Everything is working great, but I get two warnings and want to fix them:
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/setup-node@v2, actions/setup-python@v2. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
Unexpected input(s) 'username', 'password', valid inputs are ['add-hosts', 'allow', 'attests', 'build-args', 'build-contexts', 'builder', 'cache-from', 'cache-to', 'cgroup-parent', 'context', 'file', 'labels', 'load', 'network', 'no-cache', 'no-cache-filters', 'outputs', 'platforms', 'provenance', 'pull', 'push', 'sbom', 'secrets', 'secret-files', 'shm-size', 'ssh', 'tags', 'target', 'ulimit', 'github-token']
Upvotes: 1
Views: 557
Reputation: 52441
The latest version of the setup-node action is v3.6.0; you can get that with actions/[email protected]
, or if you're okay with minor versions being updated transparently, @v3
. This'll get rid of the node12 warning.
The build-push-action
action simply doesn't have any inputs for username
or password
; see the definition in the action.yml
file as the source of truth.
Notice that v3 is outdated here as well; the most recent version is v4.0.0. I highly recommend setting up dependabot to get automated version updates.
Upvotes: 0