Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add tagName and tagMessage options #78

Merged
merged 5 commits into from Jan 18, 2020
Merged

Conversation

peaceiris
Copy link
Owner

@peaceiris peaceiris commented Jan 12, 2020

Close #76

  • Update readme.md

peaceiris added a commit to peaceiris/nextjs-test that referenced this pull request Jan 12, 2020
@peaceiris
Copy link
Owner Author

peaceiris commented Jan 12, 2020

Workflow Example

YAML file:

name: github pages

on:
  push:
    branches:
    - master
    tags:
    - 'v*.*.*'

jobs:
  build-deploy:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2

    - name: setup node
      uses: actions/setup-node@v1
      with:
        node-version: '12.x'

    - name: Get yarn cache
      id: yarn-cache
      run: echo "::set-output name=dir::$(yarn cache dir)"

    - uses: actions/cache@v1
      with:
        path: ${{ steps.yarn-cache.outputs.dir }}
        key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
        restore-keys: |
          ${{ runner.os }}-yarn-

    - run: yarn install
    - run: yarn build
    - run: yarn export
    - run: touch ./out/.nojekyll

    - name: Prepare tag
      id: prepare_tag
      if: startsWith(github.ref, 'refs/tags/')
      run: |
        TAG_NAME="${GITHUB_REF##refs/tags/}"
        echo "::set-output name=tag_name::${TAG_NAME}"
        echo "::set-output name=deploy_tag_name::deploy-${TAG_NAME}"

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v2.10.0-0
      # uses: docker://peaceiris/gh-pages:v2.10.0-0
      env:
        ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
        PUBLISH_BRANCH: gh-pages
        PUBLISH_DIR: ./out
      with:
        tagName: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
        tagMessage: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'

Commands on a local machine

npm version patch  # Create a tag v0.1.4

git push origin master
# A job triggered by a "branches push event" starts.
# Wait a second for a job triggered by a "branches push event" to prevent a conflict with the next job.

git push origin v0.1.4  # push the tag v0.1.4
# A job triggered by a "tags push event" starts.
$ git fetch
$ git tag
deploy-v0.1.3
deploy-v0.1.4
v0.1.3
v0.1.4

We can also push tags as follows.

git push origin --tags
# OR
git push origin "v$(jq -r '.version' ./package.json)"

@peaceiris
Copy link
Owner Author

@cinderblock
Please test peaceiris/actions-gh-pages@v2.10.0-0.

@cinderblock
Copy link

Nicely done! Haven't had time to test yet. What about an option to force/replace an existing tag?

@peaceiris
Copy link
Owner Author

peaceiris commented Jan 12, 2020

Do you have any use cases of force/replace options? I have no idea and it looks dangerous for me.

@cinderblock
Copy link

Maybe a mistake was made an someone wants to replace a wrong tag.

Yes, it is "dangerous", and that's why it should not be enabled by default. But it should be an option.

It's just the --force option on git tag.

@peaceiris
Copy link
Owner Author

Add tagOverwrite: true to peaceiris/actions-gh-pages@v2.10.0-1.

@peaceiris peaceiris marked this pull request as ready for review January 18, 2020 03:54
@peaceiris peaceiris merged commit 9ba947f into master Jan 18, 2020
@peaceiris peaceiris deleted the feat-tagname-option branch January 18, 2020 03:55
@peaceiris
Copy link
Owner Author

v2.10.0 has been released and the stable tag v2 updated.
Thank you!

https://github.com/peaceiris/actions-gh-pages/releases/tag/v2.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proposal: Create Tag on Commit
2 participants