Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Shy/contentful-action
https://github.com/Shy/contentful-action
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Shy/contentful-action
- Owner: contentful
- License: mit
- Archived: true
- Created: 2019-11-08T19:07:46.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-21T14:07:49.000Z (over 3 years ago)
- Last Synced: 2024-05-22T23:46:18.958Z (6 months ago)
- Language: JavaScript
- Size: 1.09 MB
- Stars: 15
- Watchers: 19
- Forks: 23
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-workflows - GitHub Action for Contentful Migration CLI
- fucking-awesome-actions - GitHub Action for Contentful Migration CLI
- awesome-actions - GitHub Action for Contentful Migration CLI
README
This Repo has moved to our userland organization. Check it out [https://github.com/contentful-userland/contentful-action](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](https://www.contentful.com/developers/docs/tutorials/cli/scripting-migrations/). You can read our [conceptual guide](https://www.contentful.com/developers/docs/concepts/deployment-pipeline/) on how to utilize Contentful Environments inside your continuous delivery pipeline.
## Usage
See our [example usage](https://github.com/contentful-labs/contentful-action-example) 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](images/version-tracking.png)
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:
```js
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:
```yml
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](LICENSE) for further details.