 	# Project configuration.
 	grunt.initConfig
 		resourceToken: process.env['RESOURCE_TOKEN'] or 'http://vtex.io'
+		gitCommit: process.env['GIT_COMMIT'] or 'GIT_COMMIT'
 		relativePath: ''
 		pkg: grunt.file.readJSON('package.json')
 		pacha: grunt.file.readJSON('tools/pachamama/pachamama.config')[0]

				expand: true
				cwd: 'build/<%= relativePath %>/'
				src: ['**', '!includes/**', '!coffee/**', '!**/*.less']
				dest: 'deploy/<%= meta.commit %>/'

			env:
				expand: true

	# Generates version folder
	grunt.registerTask 'gen-version', ->
		env = this.args[0] or 'dev'
		grunt.log.writeln 'Deploying to environment: ' + env
		grunt.log.writeln 'VTEX IO Directory: ' + grunt.config('pacha').infrastructure.s3.bucket
		grunt.log.writeln 'Version set by environment variable GIT_COMMIT to: ' + grunt.config('gitCommit')
		grunt.config 'meta.env', env
		grunt.task.run ['copy:env', 'string-replace:deploy']

	# Deploy - creates deploy folder structure
	grunt.registerTask 'deploy', ->
		env = this.args[0] or 'dev'
		commit = grunt.config('gitCommit')
		if fs.existsSync 'deploy/' + commit
			grunt.log.writeln 'Folder '.cyan + commit.green + ' alredy exists. Skipping build process and generating environment folder.'.cyan
			grunt.task.run ['gen-version:' + env]
		else
			grunt.task.run ['prod', 'jasmine', 'gen-version:' + env, 'copy:deploy']

	# Example usage of deploy task
	grunt.registerTask 'deploy-example', ['deploy:master']

