forked from aboutcode-org/scancode-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from kickmaker/cd/deploy-new-release-in-gitlab-…
…container-registry cd: deploy: build docker image n gitlab container registry on new release creation Signed-off-by: Romain Pelletant <[email protected]>
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Nightly sync latest release from upstream | ||
|
||
on: | ||
push | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Sync latest release | ||
run: | | ||
# Récupérer la dernière release du repository d'origine | ||
LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" "https://api.github.com/repos/nexB/scancode-toolkit/releases/latest") | ||
# Extraire les informations de la dernière release | ||
release_name=$(echo "$LATEST_RELEASE" | jq -r '.name') | ||
release_tag=$(echo "$LATEST_RELEASE" | jq -r '.tag_name') | ||
release_body=$(echo "$LATEST_RELEASE" | jq -r '.body') | ||
# Récupérer la dernière release du repository d'origine | ||
CURRENT_LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" "https://api.github.com/repos/kickmaker/scancode-toolkit/releases/latest") | ||
current_release_tag=$(echo "$CURRENT_LATEST_RELEASE" | jq -r '.tag_name') | ||
echo $release_tag | ||
echo $current_release_tag | ||
# Check if the latest upstream release tag is different from the current fork release tag | ||
if [ "$release_tag" != "$current_release_tag" ]; then | ||
# Create the latest release in the fork repository | ||
curl -X POST \ | ||
-H "Authorization: token ${{ secrets.GH_TOKEN }}" \ | ||
-H "Content-Type: application/json" \ | ||
https://api.github.com/repos/kickmaker/scancode-toolkit/releases \ | ||
-d '{"tag_name": "${{release_tag}}", "name": "${release_name}", "body": "${release_body}"}' | ||
else | ||
echo "Latest release tag is the same as the current release tag. Skipping release creation." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build and push docker image on new release creation | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to gitLab container registry | ||
run: echo "${{ secrets.GITLAB_TOKEN }}" | docker login -u ${{ secrets.GITLAB_USERNAME }} --password-stdin ${{ secrets.GITLAB_REGISTRY_URL }} | ||
|
||
- name: Build and push docker image | ||
run: | | ||
docker build -t ${{ secrets.GITLAB_REGISTRY_URL }}/$IMAGE_NAME:${{ github.event.release.tag_name }} . | ||
docker push ${{ secrets.GITLAB_REGISTRY_URL }}/$IMAGE_NAME:${{ github.event.release.tag_name }} | ||
env: | ||
GITLAB_REGISTRY_URL: ${{ secrets.GITLAB_REGISTRY_URL }} | ||
IMAGE_NAME: scancode-toolkit | ||
TAG: ${{ github.event.release.tag_name }} | ||
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }} | ||
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} |