Giter VIP home page Giter VIP logo

publish-devto's Introduction

📮 publish-devto

Build Status XO code style License

GitHub Action to publish markdown files as articles on dev.to platform, with assets hosted on GitHub.

Usage

See action.yml.

steps:
- uses: actions/checkout@v2
- name: Publish articles on dev.to
  uses: sinedied/publish-devto@v2
  with:
    # Your dev.to personal API key to publish and update articles.
    # See https://docs.dev.to/api/#section/Authentication/api_key
    devto_key: ${{ secrets.DEVTO_TOKEN }}
    # Your GitHub personal access token, used to create commits for updated files.
    # If you have a protected branch, you need to use a personal access token
    # with the 'repo' permission.
    # See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
    github_token: ${{ secrets.GITHUB_TOKEN }}
    # (Optional) The files to publish. Default is "posts/**/*.md"
    files: 'posts/**/*.md'
    # (Optional) The git branch to use. Default is 'main'.
    branch: main
    # (Optional) Use conventional commit messages. Default is false.
    # See https://www.conventionalcommits.org. 
    conventional_commits: true
    # (Optional) Do not make actual changes on dev.to.
    dry_run: false

You can use this template repository as an example setup.

Using a custom committer

You can specify who you want to appear in the commits made by this action by adding these environment variables to the action:

  env:
    GIT_COMMITTER_NAME: your_name
    GIT_COMMITTER_EMAIL: [email protected]

How does it work?

This github action delegates most of the work to the devto-cli push command.

You can find more information about how it works in the CLI readme.

publish-devto's People

Contributors

dependabot[bot] avatar pabloromeo avatar sinedied avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

publish-devto's Issues

Failed to commit

I'm getting the following error:
remote: Permission to samyfodil/devto_articles.git denied to github-actions[bot]. fatal: unable to access 'https://github.com/samyfodil/devto_articles.git/': The requested URL returned error: 403 Error: Error: Cannot commit changes: The process '/usr/bin/git' failed with exit code 128

Git commit attempted even when no changes are present in the working tree

In the event of updating content for a draft that has already been previously created and uplodaed by this action, the git commit action fails, since there are no local changes to commit.

For example:
image

I'm guessing prior to issuing the commit it should check if the working tree is clean and not run it.

Error: end of the stream or a document separator is expected

Using the template and every time is the same error:

Run sinedied/publish-devto@v2
  with:
    devto_key: ***
    github_token: ***
    files: posts/**/*.md
    branch: main
    conventional_commits: true
    dry_run: false
  
Found 1 article(s)
- Retrieving articles from dev.to…
Error: end of the stream or a document separator is expected at line 9, column 1:
    One of the most basic uses of th ... 
    ^
Push failed

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/[2](https://github.com/k1lgor/publish-to-devto/actions/runs/4155968053/jobs/7189424736#step:3:2)022-[10](https://github.com/k1lgor/publish-to-devto/actions/runs/4155968053/jobs/7189424736#step:3:11)-[11](https://github.com/k1lgor/publish-to-devto/actions/runs/4155968053/jobs/7189424736#step:3:12)-github-actions-deprecating-save-state-and-set-output-commands/
Error: Error: Table must define at least one row.

the md file starts:

---
title: Discovering the Power of xargs command in Linux
published: false
description: Test post
tags: 'bash, linux, beginners'
cover-image: ./assets/post-6.jpg
canonical_url: null
---

## _**Compressing and Archiving Files with tar: Examples and Tips**_

### _**Introduction**_

Failed to deploy - error doesn't give enough info

Trying to deploy my first md to dev.to with this github action. Not sure if the issue is how I set up Dev.to or how I set up this action. Deploy is here. Dev.to token is in the secret.

Run sinedied/publish-devto@v2
  with:
    devto_key: ***
    branch: main
    files: blog/**/*.md
    conventional_commits: true
    dry_run: false
  env:
    deployment_status: success
Warning: Can't add secret mask for empty string in ##[add-mask] command.
Found 1 article(s)
- Retrieving articles from dev.to…
blog/[2](https://github.com/dfberry/dfberry.github.io/actions/runs/4100756031/jobs/7071870337#step:8:2)02[3](https://github.com/dfberry/dfberry.github.io/actions/runs/4100756031/jobs/7071870337#step:8:3)-01-blog.md has error(s):
- Update failed: HTTPError: Response code [4](https://github.com/dfberry/dfberry.github.io/actions/runs/4100756031/jobs/7071870337#step:8:4)22 (Unprocessable Entity)
[FAILED] [DRAFT] TypeScript type guard for empty JSON object           
No detected changes, skipping commit step.

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-[10](https://github.com/dfberry/dfberry.github.io/actions/runs/4100756031/jobs/7071870337#step:8:11)-11-github-actions-deprecating-save-state-and-set-output-commands/

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-[11](https://github.com/dfberry/dfberry.github.io/actions/runs/4100756031/jobs/7071870337#step:8:12)-github-actions-deprecating-save-state-and-set-output-commands/

How to configure publish.yml for images?

name: publish
on:
  push:
    branches:
      - master

jobs:
  publish:
    runs-on: ubuntu-latest
    if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: 12
  
    - name: Publish articles on dev.to
      uses: "sinedied/publish-devto@v2"
      with:
        files: 'content/posts/**/*.md'
        devto_key: ${{ secrets.DEVTO_TOKEN }}
        github_token: ${{ secrets.GH_TOKEN }}
        branch: master
        conventional_commits: true

and my markdown post is like
content/posts/post1.md

---
layout: post
title: 'Running GUI apps from docker inside WSL2.0 as standalone application'
author: rushi
categories: [vpn, digitalocean]
image: '/img/cover.jpg'
featured: true
hidden: false
---

## Hello world


![](/img/test.jpg)

and the error I'm getting is like

content/posts/2020-08-19-DockerGUIwsl.md has error(s):
- Image https://raw.githubusercontent.com/rushichaudhari/rushichaudhari.github.io/main/img/2020-08-19-DockerGUIwsl/image-20200819110253538.png is offline
content/posts/2020-10-29-Setting-up-tigervncserver-on-arch-linux-(raspberry-pi).md has error(s):
- Image https://raw.githubusercontent.com/rushichaudhari/rushichaudhari.github.io/main/content/img/2020-10-29-Setting-up-tigervncserver-on-arch-linux-(raspberry-pi is offline
content/posts/2020-11-28-adding-netlify-cms-to-existing-github-pages-site-within-10-minutes.md has error(s):
- Update failed: HTTPError: Response code 429 (Too Many Requests)

Deploy fail due to Jekyll `include` syntax - How to FIX?

Hi,

Thanks for creating this lib @sinedied . I have QQ, when I have blog post usually with these contents

{% include <site>.html %}

Now to be honest i'm really no clue how is this action is parsing that above. Like if it reads the html file directly and parses as markdown. The problem actually is even within that <site>.html file, I have some kramdown syntax in there, which is not compatible with markdown:

Blah blah... lolol
{: .notice--info}

Just an example of course. Now I'm not 100% sure how this action is parsing it. But in either case it's failing it with a nondescriptive error. I had to do trail-and-error to figure out that the cause is because of {% include ... %} syntax.

Q

Ideally, my Q here is as follow:

  • How do the publish-devto know to exclude when it encounter such a syntax like:
    {% include ... %}
    E.g. does it try to evaluate it and read html file, and that's why its failing, it encounter kramdown? or does it fail just because it sees include syntax?
  • How can I work around this. Ideally I will like to skip that line that starting with {% include ... %} altogether. How can I achieve this. I tried modifying it in yml directly, but deploy still fails I guess because git status --porcelain shows error, since file is modified since i had to remove that offending line.
  • If above else not possible, I like to pass markdown contents instead of markdown file. Is that possible currently? Will it solve git status issue where it's trying to check if no dirty changes checked out before it commits to dev.to or update on GH?

Appreciate help or clarification on this. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.