Skip to content

atlasaction: change input prefix for Gitlab CI (#255) #208

atlasaction: change input prefix for Gitlab CI (#255)

atlasaction: change input prefix for Gitlab CI (#255) #208

Workflow file for this run

name: Build and Upload to CDN
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit SHA'
required: false
version:
description: 'Version (should follow semver v1.2.3)'
required: false
push:
branches:
- master
tags:
- 'v*'
jobs:
test:
uses: ./.github/workflows/ci-go.yaml
secrets: inherit
build:
needs: test
runs-on: ubuntu-latest
steps:
- name: Install Atlas
uses: ariga/setup-atlas@v0
- name: Checkout code
uses: actions/[email protected]
with:
ref: ${{ github.event.inputs.commit || 'master' }}
- name: Setup Go Environment
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Set BINARY_NAME
id: set_binary_name
env:
VERSION: ${{ github.event.inputs.version || github.ref_name }}
run: |
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "BINARY_NAME=atlas-action-$VERSION" >> $GITHUB_ENV
- name: Compile Go Binary
run: |
COMMIT=$(git rev-parse --short HEAD)
go build -o atlas-action -ldflags "-s -w -X main.version=$VERSION -X main.commit=$COMMIT" ./cmd/atlas-action
OUTPUT=$(./atlas-action --version)
if [[ $(echo $OUTPUT | grep -i "^atlas-action version $VERSION-$COMMIT") ]]; then
echo "Version=$OUTPUT"
else
echo "unexpected output: $OUTPUT, expected: atlas-action version $VERSION-$COMMIT"
exit 1
fi
env:
CGO_ENABLED: 0
- name: Configure AWS credentials
run: |
aws configure set aws_access_key_id ${{ secrets.RELEASE_AWS_ACCESS_KEY_ID }}
aws configure set aws_secret_access_key ${{ secrets.RELEASE_AWS_SECRET_ACCESS_KEY }}
- name: Upload binary to S3
run: |
aws s3 cp ./atlas-action s3://release.ariga.io/atlas-action/$BINARY_NAME
env:
AWS_REGION: us-east-1
# Run end-to-end test on the published binary.
e2e-test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_TOKEN }}
- name: Run Migrate Lint
env:
GITHUB_TOKEN: ${{ github.token }}
uses: jenseng/dynamic-uses@v1
with:
uses: ariga/atlas-action/migrate/lint@${{ github.event.inputs.version || 'v1' }}
with: '{
"dir": "file://atlasaction/testdata/migrations",
"dev-url": "sqlite://dev?mode=memory",
"dir-name": "test-dir-sqlite"
}'
- name: Run Migrate Push
uses: jenseng/dynamic-uses@v1
with:
uses: ariga/atlas-action/migrate/push@${{ github.event.inputs.version || 'v1' }}
with: '{
"dir": "file://atlasaction/testdata/migrations",
"dev-url": "sqlite://dev?mode=memory",
"dir-name": "test-dir-sqlite"
}'