Giter VIP home page Giter VIP logo

contentful-action's Introduction

This Repo has moved to our userland organization. Check it out https://github.com/contentful-userland/contentful-action.

Contentful Actions

An action for running migration scripts against a Contentful CLI. To learn about making changes to a content model and entries on a Contentful Space using the Contentful CLI check out our tutorial on Scripting Migrations. You can read our conceptual guide on how to utilize Contentful Environments inside your continuous delivery pipeline.

Usage

See our example usage in our contentful-action-example repository.

This action requires a folder labeled migration inside your repo. You should place all your migrations in this directory.

For this action to know which migrations it should run, we’ll need to track which migrations have been run by adding a version number into Contentful. We accomplish this in Contentful by creating a new content model with an ID of versionTracking that has a single short-text-field named version.

Screenshot of Contentful Version Tracking Entry

You’ll also need to create one entry of your new content model with the value 1. We’ll need to create an empty migration file to represent the initial import. Create 1.js inside your migration folder and include the following code:

module.exports = function runMigration(migration) {
  return;
};

Going forward you can create a JavaScript file with an increasing integer such as 2.js, 3.js and so on. The action by default looks for a folder labeled migration but it's configurable via the environment variable MIGRATIONS_DIR.

Lastly you'll need to update your workflow file to use this action and update the settings to include your SPACE_ID and MANAGEMENT_API_KEY from Contentful. Update your main.yml file by adding the following step:

  uses: contentful/contentful-action@v1
  env: # Set the secret as an input
    SPACE_ID: ${{ secrets.SPACE_ID }}
    MANAGEMENT_API_KEY: ${{ secrets.MANAGEMENT_API_KEY }}
#   MIGRATIONS_DIR: ${{ secrets.MIGRATIONS_DIR }}

License

Copyright (c) 2019 Contentful GmbH. Code released under the MIT license. See LICENSE for further details.

contentful-action's People

Contributors

dependabot[bot] avatar shy avatar stefanjudis avatar

Stargazers

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

Watchers

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

contentful-action's Issues

ENVIRONEMNT_ID does not include branch name

Reading through the source code the ENVIRONMENT_ID should include the branch name.

source: https://github.com/contentful/contentful-action/blob/main/index.js#L44-L66

Expected Behavior:

GH-my-branch-name

Actual Behavior:

GH-merge

Context

Running with the following configuration
Running on feature branch
ENVIRONMENT_ID: GH-merge
Checking for existing versions of environment: GH-merge
Environment not found
Creating environment GH-merge

workflow/action

      - uses: contentful/contentful-action@v1
        env:
          SPACE_ID: ${{ secrets.SPACE_ID }}
          MANAGEMENT_API_KEY: ${{ secrets.MANAGEMENT_API_KEY }}

I also looked through https://github.com/contentful-labs/contentful-action-example but found no hints to faulty usage from our side.

Are you interested in ownership of our fork?

We forked this action and fixed some issues we experienced while testing. Since we also wanted to add a few features we decided to do a full rewrite (still very much based on your original implementation)

We, from EVERNEST, would like to offer you the ownership of this fork and would be willing to prepare a PR including our changes.
Our modified version is available on the github marketplace

You can read about the modifications in the README

tldr;

  • optionally set-alias
  • optionally delete-feature (delete sandbox-environment once merged)
  • use arguments (with) instead of env
  • allow environment naming patterns (i.e. prod-[DD].[MM].[YY]-[hh][mm][ss])
  • allows setting the content-type and field-id
  • allows setting the migration-dir
  • allows verbose logs (via LOG_LEVEL="verbose")
  • allows semantic versioning (i.e. v1.2.3-rc.4)

@Shy @stefanjudis

Don't create an environment if there is no new migration

Hello 👋

Right now a new environment is created even if there is no new migration.
Is there a good reason behind this? Because I think it will better to skip the creation in that case and just return the master environment.
I'm asking because, as you know, Contentful has a very very limited number of environments allowed.

I'd like to get your opinion first, and I can create a PR if we agree on something (we can also think of adding an optional flag).

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.