diff --git a/.github/workflows/dev-build.yaml b/.github/workflows/dev-build.yaml new file mode 100644 index 0000000..31b7d56 --- /dev/null +++ b/.github/workflows/dev-build.yaml @@ -0,0 +1,47 @@ +name: (DEV) Build + +on: + push: + branches: + - 'master' + paths-ignore: + - '.github/**' + +jobs: + build: + name: Build Image + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ steps.login-ecr.outputs.registry }}/${{ secrets.ECR_REPOSITORY_WALLET }} + tags: | + type=sha + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v5 + with: + file: infra/docker/Dockerfile + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile deleted file mode 100644 index 4378dbc..0000000 --- a/ci/Jenkinsfile +++ /dev/null @@ -1,119 +0,0 @@ -def buildNumber = env.BUILD_NUMBER as int -if (buildNumber > 1) milestone(buildNumber - 1) -milestone(buildNumber) - -pipeline { - - agent any - - environment { - registry = '494750395663.dkr.ecr.us-east-1.amazonaws.com/make/casper' - app = 'wallet' - dockerImage = '/$app' - GIT_HASH = GIT_COMMIT.take(7) - AWS_DEFAULT_REGION = 'us-east-1' - } - - stages { - - stage('Build image') { - when { - anyOf { - branch "develop"; - branch "master"; - branch "rc-1*" - } - } - steps { - script { - sh "until docker ps; do sleep 3; done && docker build -t $registry$dockerImage:${env.GIT_HASH} -f ci/docker/Dockerfile ." - } - } - } - - stage('Push image') { - when { - anyOf { - branch "develop"; - branch "master"; - branch "rc-1*" - } - } - steps { - script { - docker.withRegistry('https://494750395663.dkr.ecr.us-east-1.amazonaws.com', 'ecr:us-east-1:make-ecr-casper-dev') { - sh "docker push $registry$dockerImage:${env.GIT_HASH}" - } - } - } - } - - stage('Clone casper-infra repo') { - when { - anyOf { - branch "develop"; - branch "master"; - branch "rc-*" - } - } - environment { - GIT_CREDS_USR = credentials('repo-git-user') - GIT_CREDS_PSW = credentials('repo-git-pass') - } - steps { - sh "git clone https://$GIT_CREDS_USR:$GIT_CREDS_PSW@bitbucket.org/makellc/casper-infra.git" - sh 'git config --global user.email \'jenkins@make.servies\'' - sh 'git config --global user.name "Jenkins CI"' - } - } - - stage('DEV') { - when { - anyOf { - branch "develop"; - branch "master"; - branch "rc-*" - } - } - environment { - env = 'dev' - dir = 'casper-wallet' - app = 'wallet' - } - steps { - dir(path: 'casper-infra') { - sh 'cd ./kubernetes/environment/$env/$dir && pwd && ls -la && sed -i "s|/$app.*|/$app:$GIT_HASH|g" $app.yaml' - sh 'git status && git commit -am "$dir-$app-$env releasing from branch $BRANCH_NAME" && pwd && ls -la && chmod a+x ../ci/push.sh && ../ci/push.sh || echo \'no changes\'' - } - } - } - - stage('ArgoCD') { - when { - anyOf { - branch "develop"; - branch "master"; - branch "rc-*" - } - } - steps { - sh 'sleep 180' - } - } - } - post { - success { - script { - if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master' || env.BRANCH_NAME =~ 'rc.*') - slackSend (color: '#00FF00', channel: "#casper-wallet-alerts", message: "SUCCESSFUL\n*Job:* `${env.JOB_NAME}`\n*Build:* `${env.BUILD_NUMBER}`\n *Commit:* `${env.GIT_HASH}`\n *More info at:* `${env.BUILD_URL}`") - } - } - - failure { - script { - if (env.BRANCH_NAME == 'develop' || env.BRANCH_NAME == 'master' || env.BRANCH_NAME =~ 'rc.*') - slackSend (color: '#FF0000', channel: "#casper-wallet-alerts", message: "FAILED\n*Job:* `${env.JOB_NAME}`\n*Build:* `${env.BUILD_NUMBER}`\n *Commit:* `${env.GIT_HASH}`\n *More info at:* `${env.BUILD_URL}`") - } - } - } -} \ No newline at end of file diff --git a/ci/push.sh b/ci/push.sh deleted file mode 100644 index 76cc19e..0000000 --- a/ci/push.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -max_retry=5 -counter=0 -until git push origin master -do - sleep 3 - [[ counter -eq $max_retry ]] && echo "Failed job!" && exit 1 - echo "Trying again. Try #$counter" && git pull origin master - ((counter++)) -done \ No newline at end of file diff --git a/ci/docker/Dockerfile b/infra/docker/Dockerfile similarity index 70% rename from ci/docker/Dockerfile rename to infra/docker/Dockerfile index 8cb64c2..4d87b73 100644 --- a/ci/docker/Dockerfile +++ b/infra/docker/Dockerfile @@ -12,5 +12,5 @@ FROM nginx:1.22.0 WORKDIR /usr/share/nginx/html COPY --from=builder /app/builder/build ./ -COPY --from=builder /app/builder/ci/docker/nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=builder /app/builder/infra/docker/nginx/nginx.conf /etc/nginx/nginx.conf diff --git a/ci/docker/nginx/nginx.conf b/infra/docker/nginx/nginx.conf similarity index 100% rename from ci/docker/nginx/nginx.conf rename to infra/docker/nginx/nginx.conf