Skip to content

Commit

Permalink
Fiddling with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
NehaNaithani committed Jan 3, 2024
1 parent cc23a9c commit a639fb7
Showing 1 changed file with 156 additions and 154 deletions.
310 changes: 156 additions & 154 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,157 +80,159 @@ jobs:
# if: always()
# run: sudo bash test/deploy_ecn.bash deleteECN
#
# Publish:
# runs-on: ubuntu-20.04
# needs: [Build, Integration]
# permissions:
# contents: 'read'
# id-token: 'write'
# packages: 'write'
# name: Publish
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: 'Get Previous tag'
# id: previoustag
# uses: "WyriHaximus/github-action-get-previous-tag@v1"
# with:
# fallback: 0.0.0
# - name: Set image tag
# shell: bash
# id: tags
# run: |
# if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
# VERSION=${{ github.ref_name }}
# echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
# else
# VERSION=${{ steps.previoustag.outputs.tag }}
# echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
# fi
# - name: Build and Push to GCR
# if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
# id: build_push_gcr
# uses: RafikFarhad/push-to-gcr-github-action@v5-beta
# with:
# gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
# registry: gcr.io
# project_id: ${{ env.PROJECT }}
# image_name: ${{ env.IMAGE_NAME }}
# image_tag: latest, develop, ${{ steps.tags.outputs.VERSION }}
# dockerfile: Dockerfile
#
# - name: Login to Github Container Registry
# if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
# uses: docker/login-action@v2
# with:
# registry: "ghcr.io"
# username: ${{ github.actor }}
# password: ${{ github.token }}
#
# - name: Build and Push to ghcr
# if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
# uses: docker/build-push-action@v3
# id: build_push_ghcr
# with:
# file: Dockerfile
# push: true
# tags: |
# ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
# ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:latest
# ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:develop
#
# - name: Set up Ruby 3.1.4
# uses: actions/setup-ruby@v1
# with:
# ruby-version: 3.1.4
# - run: |
# gem install --no-document fpm
# fpm -h
# - name: Install package_Cloud
# run: |
# gem install package_cloud
# package_cloud -h
# - name: get gradle version
# shell: bash
# id: version
# run: echo "version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')" >> "${GITHUB_OUTPUT}"
# - name: get package version
# shell: bash
# id: pkg_version
# run: |
# if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
# echo "version=${{ steps.version.outputs.version }}" >> "${GITHUB_OUTPUT}"
# else
# echo "version=${{ steps.version.outputs.version }}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
# fi
# - run: echo ${{ steps.version.outputs.version }}
# - name: Create deb package
# shell: bash
# id: create_deb_package
# run: |
# cd packaging/iofog-agent
# fpm -s dir -d 'openjdk-8-jdk | openjdk-11-jdk | openjdk-17-jdk' -d docker -t deb -n iofog-agent -v ${{ steps.pkg_version.outputs.version }} -a all --deb-no-default-config-files --after-install debian.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade debian.sh etc usr
# echo "pkg created"
# ls
# - name: Create rpm package
# shell: bash
# id: create_rpm_package
# run: |
# cd packaging/iofog-agent
# fpm -s dir --depends 'java-17-openjdk' -d docker-ce -t rpm -n iofog-agent -v ${{ steps.pkg_version.outputs.version }} -a all --rpm-os 'linux' --after-install rpm.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade rpm.sh etc usr;
# echo "pkg created"
# ls
# - uses: actions/upload-artifact@v2
# name: Upload deb package
# with:
# name: deb-package
# path: packaging/iofog-agent/iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb
#
# - uses: bluwy/substitute-string-action@v1
# id: sub
# with:
# _input-text: ${{ steps.pkg_version.outputs.version }}
# '-': _
# - run: echo ${{ steps.sub.outputs.result }}
#
# - uses: actions/upload-artifact@v2
# name: Upload rpm package
# with:
# name: rpm-package
# path: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm
#
# - uses: actions/download-artifact@v2
# with:
# name: deb-package
#
# - name: Publish deb package to packagecloud
# uses: danielmundi/upload-packagecloud@v1
# with:
# PACKAGE-NAME: iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb
# PACKAGECLOUD-USERNAME: iofog
# PACKAGECLOUD-REPO: iofog-agent-dev
# PACKAGECLOUD-DISTRIB: any/any
# PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}
#
# - uses: actions/download-artifact@v2
# with:
# name: rpm-package
#
# - name: Publish rpm package to packagecloud
# uses: danielmundi/upload-packagecloud@v1
# with:
# PACKAGE-NAME: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm
# PACKAGECLOUD-USERNAME: iofog
# PACKAGECLOUD-REPO: iofog-agent-dev
# PACKAGECLOUD-DISTRIB: rpm_any/rpm_any
# PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}
#
# - name: Upload Agent Artifact
# uses: actions/upload-artifact@v3
# with:
# name: agent
# path: packaging/**/*
#
#
#
Publish:
runs-on: ubuntu-20.04
needs: [Build]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
name: Publish
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.0
- name: Set image tag
shell: bash
id: tags
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
VERSION=${{ github.ref_name }}
echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
else
VERSION=${{ steps.previoustag.outputs.tag }}
echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- name: Build and Push to GCR
if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
id: build_push_gcr
uses: RafikFarhad/push-to-gcr-github-action@v5-beta
with:
gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
registry: gcr.io
project_id: ${{ env.PROJECT }}
image_name: ${{ env.IMAGE_NAME }}
image_tag: latest, develop, ${{ steps.tags.outputs.VERSION }}
dockerfile: Dockerfile

- name: Login to Github Container Registry
if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build and Push to ghcr
if: (github.ref == 'refs/heads/develop') || contains(github.ref_name, '^v.*')
uses: docker/build-push-action@v3
id: build_push_ghcr
with:
file: Dockerfile
push: true
tags: |
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:latest
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:develop
- name: Set up Ruby 3.1.4
uses: actions/setup-ruby@v1
with:
ruby-version: 3.1.4
- run: |
gem install --no-document fpm
fpm -h
- name: Install package_Cloud
run: |
gem install package_cloud
package_cloud -h
- name: get gradle version
shell: bash
id: version
run: echo "version=$(./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}')" >> "${GITHUB_OUTPUT}"
- name: get package version
shell: bash
id: pkg_version
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
echo "version=${{ steps.version.outputs.version }}" >> "${GITHUB_OUTPUT}"
else
echo "version=${{ steps.version.outputs.version }}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- run: echo ${{ steps.version.outputs.version }}
- name: Create deb package
shell: bash
id: create_deb_package
run: |
cd packaging/iofog-agent
fpm -s dir -d 'openjdk-8-jdk | openjdk-11-jdk | openjdk-17-jdk' -d docker -t deb -n iofog-agent -v ${{ steps.pkg_version.outputs.version }} -a all --deb-no-default-config-files --after-install debian.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade debian.sh etc usr
echo "pkg created"
ls
cd packaging/iofog-agent/usr/bin
ls
- name: Create rpm package
shell: bash
id: create_rpm_package
run: |
cd packaging/iofog-agent
fpm -s dir --depends 'java-17-openjdk' -d docker-ce -t rpm -n iofog-agent -v ${{ steps.pkg_version.outputs.version }} -a all --rpm-os 'linux' --after-install rpm.sh --after-remove remove.sh --before-upgrade upgrade.sh --after-upgrade rpm.sh etc usr;
echo "pkg created"
ls
- uses: actions/upload-artifact@v2
name: Upload deb package
with:
name: deb-package
path: packaging/iofog-agent/iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb

- uses: bluwy/substitute-string-action@v1
id: sub
with:
_input-text: ${{ steps.pkg_version.outputs.version }}
'-': _
- run: echo ${{ steps.sub.outputs.result }}

- uses: actions/upload-artifact@v2
name: Upload rpm package
with:
name: rpm-package
path: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm

- uses: actions/download-artifact@v2
with:
name: deb-package

- name: Publish deb package to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: iofog-agent_${{ steps.pkg_version.outputs.version }}_all.deb
PACKAGECLOUD-USERNAME: iofog
PACKAGECLOUD-REPO: iofog-agent-dev
PACKAGECLOUD-DISTRIB: any/any
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}

- uses: actions/download-artifact@v2
with:
name: rpm-package

- name: Publish rpm package to packagecloud
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: packaging/iofog-agent/iofog-agent-${{ steps.sub.outputs.result }}-1.noarch.rpm
PACKAGECLOUD-USERNAME: iofog
PACKAGECLOUD-REPO: iofog-agent-dev
PACKAGECLOUD-DISTRIB: rpm_any/rpm_any
PACKAGECLOUD-TOKEN: ${{ secrets.packagecloud_token }}

- name: Upload Agent Artifact
uses: actions/upload-artifact@v3
with:
name: agent
path: packaging/**/*



0 comments on commit a639fb7

Please sign in to comment.