Skip to content

Commit

Permalink
Merge pull request #3 from matheuspolitano/1-fix-main-bugs-2
Browse files Browse the repository at this point in the history
fix pipeline
  • Loading branch information
matheuspolitano authored Dec 24, 2024
2 parents 011b3a8 + fee950d commit 6df7c14
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions .github/workflows/move-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Move release file into `releases` folder
name: Move release file into releases folder

on:
push:
branches:
- main # or whichever branch you merge into
- main

permissions:
contents: write

jobs:
move_release_file:
Expand All @@ -12,32 +15,35 @@ jobs:
- name: Check out repository
uses: actions/checkout@v3
with:
persist-credentials: true # needed to push back to the repo
persist-credentials: true # Allows push back to the repo

- name: Move file to releases folder and rename with timestamp
- name: Set up environment variables (timestamp, file paths)
id: setvars
run: |
# Timestamp format: YYYYMMDDHHMMSS
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
echo "RELEASE_SOURCE_FILE=release.toml" >> $GITHUB_ENV
echo "RELEASE_FOLDER=releases" >> $GITHUB_ENV
echo "RELEASE_TARGET_FILE=release_${TIMESTAMP}.toml" >> $GITHUB_ENV
# Adjust these paths to match your setup
RELEASE_SOURCE_FILE="release.toml"
RELEASE_FOLDER="releases"
RELEASE_TARGET_FILE="releases_${TIMESTAMP}.toml"
# Create the releases folder if it doesn't exist
mkdir -p "${RELEASE_FOLDER}"
# Move or copy the file (depending on whether you want to preserve the original)
cp "${RELEASE_SOURCE_FILE}" "${RELEASE_FOLDER}/${RELEASE_TARGET_FILE}"
- name: Move file to releases folder
run: |
echo "Using TIMESTAMP=$TIMESTAMP"
echo "Copying $RELEASE_SOURCE_FILE to $RELEASE_FOLDER/$RELEASE_TARGET_FILE"
mkdir -p "$RELEASE_FOLDER"
cp "$RELEASE_SOURCE_FILE" "$RELEASE_FOLDER/$RELEASE_TARGET_FILE"
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "${RELEASE_FOLDER}/${RELEASE_TARGET_FILE}"
git commit -m "Add new release file ${RELEASE_TARGET_FILE}"
git add "$RELEASE_FOLDER/$RELEASE_TARGET_FILE"
git commit -m "Add new release file $RELEASE_TARGET_FILE"
git push
env:
# This lets you push using the GitHub Actions token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# So we can use $TIMESTAMP, $RELEASE_FOLDER, and $RELEASE_TARGET_FILE again
TIMESTAMP: ${{ env.TIMESTAMP }}
RELEASE_FOLDER: ${{ env.RELEASE_FOLDER }}
RELEASE_TARGET_FILE: ${{ env.RELEASE_TARGET_FILE }}

0 comments on commit 6df7c14

Please sign in to comment.